Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Expert System in Ergo Lite Problem with Reading User Input

3 views
Skip to first unread message

Jason Morris

unread,
Oct 25, 2020, 4:01:34 AM10/25/20
to ErgoAI, Flora-2, and XSB Users Forum
I'm attempting to re-implement the "native" shell from Merrit's Expert Systems in Prolog using Flora-2, and have made good progress, but I'm running into a problem with the ask predicate.

The version of the predicate I'm using looks like this, right now:
%ask(?A,?V,?Hist) :-
 write('Is ')@\io,  // if we get here, we need to ask.
 write(?A)@\io,
 write(' ')@\io,
 write(?V)@\io,
 write('? (yes or no) ')@\io,
 get_user(?Y,?Hist), // get the answer
 write('The answer received was ')@\io,
 write(?Y)@\io,
 write('\n')@\io,
 insert{known(?Y,?A,?V)}, // remember it so we dont ask again.
 ?Y == 'yes'. // succeed or fail based on answer.

Forgive the mess.

get_user\2 looks like this:

get_user(?X,?Hist) :-
 \loop (
  write('> ')@\io,
  read(?X,?Stat)@\io,
  %process_ans(?X,?Hist)
 )
 \until ok \in ?Stat.

The expected behaviour is that the person will type `yes.` at the prompt, or `no.`.
The last line of ask is supposed to cause the predicate to fail if the answer was no,
or succeed if it was anything else.  But what gets printed out is something like 'the answer received is ?_h123', regardless of what the user puts into the tool.

I suspect there is something to do with how terms are collected using read\2@\io that I don't quite understand. Hoping someone here might be able to help.  Thanks in advace.

Jason

Michael Kifer

unread,
Oct 26, 2020, 3:14:47 AM10/26/20
to ErgoAI-Flor...@coherentknowledge.com

loop-until and while-loop do not bind any variables. Should have been mentioned in the manual.

Second,  read(?X,?Stat)@\io was probably meant to be @\parse.


I am not sure what you wanted to do with ?Hist but you would probably have to use updates for that.

--

       --- michael


 

--
You received this message because you are subscribed to the Google Groups "ErgoAI, Flora-2, and XSB Users Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ErgoAI-Flora2-XSB...@coherentknowledge.com.
To view this discussion on the web visit https://groups.google.com/a/coherentknowledge.com/d/msgid/ErgoAI-Flora2-XSB-forum/f32a44c6-6fd6-4b2c-b6d4-8d8826e9d8b1n%40coherentknowledge.com.
Reply all
Reply to author
Forward
0 new messages