i trying learn how write production rules in prolog. have.
paragraph --> sentence, paragraph ; []. sentence --> proper_noun, [ ], verb, [ ], preposition, [ ], article, [ ], noun, period. proper_noun --> [jimmy] ; [yancy] ; [clementine] ; [astrid]. verb --> [runs] ; [walks] ; [skips] ; [flies]. preposition --> [to] ; [at] ; [around] ; [through]. article --> [the] ; [a]. noun --> [school] ; [house] ; [car] ; [spaceship]. period -->[.].
i tried call using
phrase( sentence, [jimmy," ",walks," ",to," ",the," ",school], [] ), atom_codes( output,[jimmy," ",walks," ",to," ",the," ",school]).
it returned false output. please me understand went wrong , how can write better grammars.
use 'jimmy'
etc. (i.e. put atoms starting capital letters quotes). otherwise interpreted logical variables. lots of "singleton variables" warnings.
you've missed parentheses, , made few more typos:
paragraph --> sentence, ( paragraph ; []). sentence --> proper_noun, verb, preposition, article, noun, period. proper_noun --> ['jimmy'] ; ['yancy'] ; ['clementine'] ; ['astrid']. verb --> [runs] ; [walks] ; [skips] ; [flies]. preposition --> [to] ; [at] ; [around] ; [through]. article --> [the] ; [a]. noun --> [school] ; [house] ; [car] ; [spaceship]. period -->[.].
testing it:
30 ?- phrase( sentence, ['jimmy', walks, to, the, school, .], [] ). true ; false.
Comments
Post a Comment