dcg - Prolog, Definite Clause Grammar -
some code wrote definite clause grammar followed book "learn prolog now" closely
lex(the,det(single)). lex(the,det(plural)). lex(a,det(single)). lex(some,det(plural)). lex(at,det(single)). lex(student,n(single)). lex(students,n(plural)). lex(assignment,n(single)). lex(assignments,n(plural)). lex(teacher,n(single)). lex(teachers,n(plural)). lex(lecture,n(single)). lex(lecture,n(plural)). lex(school,n(single)). lex(home,n(single)). lex(does,v(single)). lex(do,v(plural)). lex(corrects,v(single)). lex(correct,v(plural)). lex(writes,v(single)). lex(write,v(plural)). lex(gives,v(single)). lex(give,v(plural)). lex(his,pro(single)). lex(her,pro(single)). lex(their,pro(plural)). lex(and,conj). lex(while,conj). s--> s, conj, s. s--> np(x),vp(x). np(x)--> det(x),n(x);pro(x), n(x). vp(x)--> v(x), np(x). vp(x)--> v(x). det(x)--> [a],{lex(a,det(x))}. pro(x)--> [a],{lex(a,pro(x))}. v(x)--> [a],{lex(a,v(x))}. n(x)--> [a],{lex(a,n(x))}.
below query asked above code
3 ?- s([the,student,does,his,assignment],[]). error: out of local stack
i tried repositioning lexicon didn't work syntax errors, nothing picked when compiled it
sorry if didn't write question don't know else say, if need more information code leave comment , i'll try answer best can.
the problem s//0 left recursive. should amend first rule. instance
s --> p, conj, s. p --> np(x),vp(x). ...
Comments
Post a Comment