Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
— |
pl:prolog:pllib:dcg_tree [2019/06/27 15:50] (aktualna) |
| ====== Dcg tree ====== |
| {{tag>DCG linguistics trees}} |
| ===== Description ===== |
| A DCG computing a parse tree |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{dcg_tree.pl}} |
| ===== Listing ===== |
| <code prolog> |
| 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 |
| </code> |
| ===== Comments ===== |
| |