The error is to do with what I’ve tried to come up with to stop the DCG from accepting answers with the wrong verb follwing a noun, such as the woman walk to the shops, instead of walks. It’s an error i don’t really understand so a fix or explanation would be great
I’m not an expert so originally I was trying to solve this using the variables assigned with the noun phrase and verb phrases and matching them up, but it wasnt going anywhere so ive used some prolog to check if the variables are the right ones, which i think is the source of the issue.
Code:
transitive_verb(plural) --> [eat]; [know]; [see]; [hire].
transitive_verb(single) --> [eats]; [knows]; [sees]; [hires].
intransitive_verb --> [sleeps].
determiner(single) --> [the]; [a]; [an]; [].
determiner(plural) --> [the]; []; [two].
pronoun(subject,single) --> [they]; [I]; [you]; [we].
pronoun(subject,plural) --> [he]; [she]; [it].
pronoun(object) --> [me]; [you]; [him]; [her]; [it]; [us]; [them].
noun(single) --> [woman]; [man]; [dog]; [apple].
noun(plural) --> [women]; [men]; [dogs]; [apples].
adjective --> [big]; [red]; [tasty].
preposition --> [on]; [under]; [beside].
% Grammar rules
sentence --> noun_phrase(N), verb_phrase(N).
noun_phrase(_) --> determiner(X), noun(X).
noun_phrase(X) --> pronoun(X).
verb_phrase --> intransitive_verb.
verb_phrase(X) --> transitive_verb(X), noun_phrase(_), { X = single ; X = plural }.
verb_phrase(subject, N) --> transitive_verb(single), noun_phrase(_), { N = plural }.
verb_phrase(subject, N) --> transitive_verb(plural), noun_phrase(_), { N = single }.
Error:
| sentence([she,knows,the,man],[]).
ERROR: Unknown procedure: sentence/2
ERROR: However, there are definitions for:
ERROR: sentence/2
ERROR:
ERROR: In:
ERROR: [12] sentence([she,knows|…],[])
ERROR: [11] toplevel_call(user:user: …) at c:/program files/swipl/boot/toplevel.pl:1317
Exception: (12) sentence([she, knows, the, man], []) ? creep
^ Exception: (4) setup_call_cleanup(‘$toplevel’:notrace(call_repl_loop_hook(begin, 0)), ‘$toplevel’:’$query_loop'(0), ‘$toplevel’:notrace(call_repl_loop_hook(end, 0))) ? creep
?-
Bradley Sparkes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.