Using SWI Prolog 7.7.2 in Ubuntu Linux, I am trying to run the "talk" module from Pereira and Schieber (Appendix A, http://www.mtome.com/Publications/PNLA/prolog-digital.pdf).
After copying, pasting into a text editor (Sublime), and adjusting line breaks to (mostly) match the original, running swipl, and then ['talk.P'], I am encountering over two dozen "Syntax error: Operator expected" errors, e.g. (with directory location replaced by [...]):
Lines 15-20:
main_loop :- write(’>> ’), % prompt the user read_sent(Words), % read a sentence talk(Words, Reply), % process it with TALK print_reply(Reply), % generate a printed reply main_loop. % process more sentencesERROR: [...]/talk.P:16:15: Syntax error: Operator expected
---Line 38:
talk(_Sentence, error(’too difficult’)).ERROR: [...]/talk.P:38:25: Syntax error: Operator expected
---Lines 76-77:
% Replying to some other type of sentence. reply(_Type, _FreeVars, _Clause, error(’unknown type’)).ERROR: [...]/talk.P:77:42: Syntax error: Operator expected
---Lines 87-91:
print_reply(error(ErrorType)) :- write(’Error: "’), write(ErrorType), write(’."’), nl. print_reply(asserted(Assertion)) :- write(’Asserted "’), write(Assertion), write(’."’), nl.ERROR: [...]/talk.P:91:12: Syntax error: Operator expected
---Note I am also encountering ten singleton variable warnings, but am not sure whether this will prove to be a problem or not, e.g.:
---Lines 59-60:
reply(query, FreeVars, (answer(Answer):-Condition), Reply) :- Warning: [...]/talk.P:59: Singleton variables:[FreeVars,Condition,FreeVarsˆCondition] Warning: [...]/talk.P:59: Singleton variable in branch: FreeVarsˆCondition
---Lines 242-243:
q(S => ‘answer(X)) --> whpron, vp(finite, XˆS, nogap).Warning: [...]/talk.P:242: Singleton variables: [S,X,XˆS]
What do I need to do to get this module up and running?
_or_<whatever_name_you_want>instead. In your case, for some reason, theXandSaren't "visible" invp(finite, X^S, nogap). Again, could be due to other syntax issues earliler. - lurkeranswer(X)?q(S => ‘answer(X)) ...? - lurkerwrite(’>> ’)is not using ASCII single quotes as required. The text is using another character code to give a single-quote character, not the simple ASCII version. Change these to normal ASCII single quotes, and that error will go away. Same with the other errors. For example,talk(_Sentence, error(’too difficult’)).uses the non-ASCII single quotes. - lurker