?? parser.pro
字號:
% Author:
% Date: 11/29/2005
:-module(parser,[parse/2,parse/0]).
:-use_module('rule.pro').
:-use_module('tokenizer.pro').
:-op(1000,xfy,'=>').
%testing command.
%parse:-forall(parse('a mouse chase the pig',X),(write(X),nl)).
parse:-forall(parse('ASF/SF2 is a protein that plays important roles in premRNA splicing',X),(write(X),nl)).
%parse(+Sentence_list,-Output), input a list of words as a sentence
parse(SentStr,S):- tokenize(SentStr,Sentence),
reset, %erase all the edges.
process(Sentence,1),
getlength(Sentence,Length), % get the length of the sentence
% Length1 is Length+1,
edge(_,_,S),
getType(S,[a(_)]) .
getType(X,X).
reset:-retractall(edge(_,_,_)).
process([Head|Tail],L):- L1 is L+1,
addedge(edge(L,L1,[Head])),
scan(L1,L1,[]),
process(Tail,L1),
fail.
process(_,_).
%scan(+Start,+L,+Clist), Start: the start position; L: scan location; Clist: completed list
scan(Start,L,Clist):- foreach((Clist=>Clist_up),
(addedge(edge(L,Start,Clist_up)),scan(Start,L,Clist_up))),
edge(L1,L,List),/*read edge C*/
append(List,Clist,NClist), /*append C to Clist*/
% write([a,NClist]),nl,
/*for each rule that start from NClist, add edge and start new scan*/
foreach((NClist=>NClist_up),
(addedge(edge(L1,Start,NClist_up)),scan(Start,L1,NClist_up))),
scan(Start,L1,NClist),fail.
scan(_,_,_).
addedge(X):- \+(X),assertz(X).
getlength([_|Tail],L):- getlength(Tail,L1),L is L1+1.
getlength([],0).
seeEdge:-edge(X,Y,Z),write([X,Y,Z]),nl,fail.
seeEdge.
foreach(X,Y):-X,once(Y),fail.
foreach(_,_).
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -