i’m new to prolog and I try to program a answering machine. At first I like to figure out for what was asked, and to check correct syntax.
question(P) --> [where],[is], article(G,K,N), location(P,G,K,N).
location(P,G,K,N) --> [P], {member(P, [bakery, mcdonalds, kfc, embassy]),noun(G,K,N)}.
article(m, akk, sg) --> [a].
article(f, akk, sg) --> [an].
noun(m, akk, sg) --> [bakery]|[mcdonalds]|[kfc].
noun(f, akk, sg) --> [embassy].
but i got this error:
question(What, [where,is,a,bakery],[]).
ERROR: location/6: Undefined procedure: noun/3
ERROR: However, there are definitions for:
ERROR: noun/5
however, i found that the last two arguments of dcg variables are some kind of lists, but i really found nothing for that topic… do you have any tipps or solution for me?
PS: I tried to translate the example from german grammar, so don’t be confused 😉
In the
locationrule, you putnouninside{}so it’s treated like an ordinary Prolog rule. Take it outside the{}and your grammar “works” (well, the parse fails, but it doesn’t throw an error).