Dcg tree


A DCG computing a parse tree

Source: The Art of Prolog


Program source code: dcg_tree.pl


        sentence(sentence(NP,VP)) --> noun_phrase(NP), verb_phrase(VP).
        noun_phrase(np(D,N)) --> determiner(D), noun_phrase2(N).
        noun_phrase(np(N)) --> noun_phrase2(N).
        noun_phrase2(np2(A,N)) --> adjective(A), noun_phrase2(N).
        noun_phrase2(np2(N)) --> noun(N).
        verb_phrase(vp(V)) --> verb(V).
        verb_phrase(vp(V,N)) --> verb(V), noun_phrase(N).
%       Vocabulary
        determiner(det(the)) --> [the].
        determiner(det(a)) --> [a].
        noun(noun(pieplate)) --> [pieplate].
        noun(noun(surprise)) --> [surprise].
        adjective(adj(decorated)) --> [decorated].
        verb(verb(contains)) --> [contains].
%      Program 19.7:  A DCG computing a parse tree


pl/prolog/pllib/dcg_tree.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0