Dcg number agreement

Description

A DCG with subject/object number agreement

Source: The Art of Prolog

Download

Program source code: dcg_number_agreement.pl

Listing

        sentence(sentence(NP,VP)) -->
            noun_phrase(NP,Num), verb_phrase(VP,Num).
 
        noun_phrase(np(D,N),Num) -->
            determiner(D,Num), noun_phrase2(N,Num).
        noun_phrase(np(N),Num) --> noun_phrase2(N,Num).
 
        noun_phrase2(np2(A,N),Num) -->
            adjective(A), noun_phrase2(N,Num).
        noun_phrase2(np2(N),Num) --> noun(N,Num).
 
        verb_phrase(vp(V),Num) --> verb(V,Num).
        verb_phrase(vp(V,N),Num) -->
            verb(V,Num), noun_phrase(N,Num1).
 
%       Vocabulary
 
        determiner(det(the),Num) --> [the].
        determiner(det(a),singular) --> [a].
 
        noun(noun(pieplate),singular) --> [pieplate].
        noun(noun(pieplates),plural) --> [pieplates].
        noun(noun(surprise),singular) --> [surprise].
        noun(noun(surprises),plural) --> [surprises].
 
        adjective(adj(decorated)) --> [decorated].
 
        verb(verb(contains),singular) --> [contains].
        verb(verb(contain),plural) --> [contain].
 
%     Program 19.8:  A DCG with subject/object number agreement

Comments

pl/prolog/pllib/dcg_number_agreement.txt · ostatnio zmienione: 2017/07/17 08:08 (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