文法規則は以下のような記述をPrologの規則や事実に変更します。 (より詳細な記述は/ClocMel/にあります)
sent --> sent(X). sent(X) --> noun_p(X),verb_p(X).
noun_p(X) --> determ(X),noun(X). verb_p(X) --> verb(X),noun_p(Y).
determ(_) --> [the]. noun(sing) --> [man]. noun(sing) --> [banana]. verb(sing) --> [loves]. verb(sing) --> [eats].
noun(plur) --> [men]. noun(plur) --> [bananas]. verb(plur) --> [love]. verb(plur) --> [eat].
次のように質問すれば、インタプリタが文法規則に従って文をチェックします。
?- phrase(sent,[the,man,eats,the,bananas]).
yes ?- _
| scroll to top |
|