Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to distinguish positive from negative input

Status
Not open for further replies.

rs86

Programmer
Jan 7, 2009
3
GB
Hi all.

I am trying to write a very simple expert system which acts as a car startup troublshooter. It currently comprises of a basic textual welcome screen and multiple questions to outline the common non-startup causes. The user has a choice to reply yes/no to these questions.
The response is assosiated with the symptom, then the symptom is then assosiated with the correct reply/solution to the promblem.

The problem is that i would like to be able to distinguish wether the questions are positive or negative to get the desired output. Currently, the system in designed to respond to negative replies i.e. 'yes' or 'y' which will trigger the appropriate reply. If the response is 'no' or 'n', the system will disgard the fault assosiated to the current question being asked.

For example, if the question is:

'can you turn the key in the ignition' and the user replies "no", the fault will be dismissed, unless the user replies "yes" to this question, the system will assert to the database as a 'fault', therefore giving the wrong solution at the end of the session.

My thought is that i should store with the question a value that reflects the "default" (or no fault) answer, so that the detection of "fault" can be made on that basis (user input differs from "default"). Any suggestions on how to acheive this?

The source code can be obtained here :

Any help will be greatly appreciated!

Thank you
 
Hi Joel, thanx for your input.

Your idea sounds like a very straight forward and suitable suggestion. My PROLOG programming knowledge is a little inapt at this stage. Do you think you could give me an example of your idea, for me to build upon?

Also, can you tell me how i would deal with user input. For example, say if the user replies 'yes' to a question, and the question is 'false', how could i prevent the fault being stored in the database, thus stopping the system outputting a reply?

Many thanks,

rs86
 
You can try this code :
Code:
collect_symptoms:-
	question(Quest,Sympt),		% output question to user
	write(Quest),nl,
	getyesno(Yesno),nl,
	(   (Yesno='yes';Yesno='y'),       % if user has symptom put into database
	     assertz(good(Sympt));
	     assertz(bad(Sympt))),
	fail.
Now, review your rules, I think you must start a rule when it's a bad fact.
With good facts and bads ones you can be more accurate in your diagnosis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top