f1b417f1c3
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@812 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
30 lines
520 B
Plaintext
30 lines
520 B
Plaintext
|
|
:- object(parsetree,
|
|
implements(parsep)).
|
|
|
|
|
|
parse(List, Tree) :-
|
|
phrase(sentence(Tree), List).
|
|
|
|
|
|
sentence(s(NP,VP)) --> noun_phrase(NP), verb_phrase(VP).
|
|
|
|
noun_phrase(np(D,NP)) --> determiner(D), noun(NP).
|
|
noun_phrase(NP) --> noun(NP).
|
|
|
|
verb_phrase(vp(V)) --> verb(V).
|
|
verb_phrase(vp(V,NP)) --> verb(V), noun_phrase(NP).
|
|
|
|
|
|
determiner(d(the)) --> [the].
|
|
determiner(d(a)) --> [a].
|
|
|
|
noun(n(boy)) --> [boy].
|
|
noun(n(girl)) --> [girl].
|
|
|
|
verb(v(likes)) --> [likes].
|
|
verb(v(hates)) --> [hates].
|
|
|
|
|
|
:- end_object.
|