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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

micro watson prolog(answering question).

Status
Not open for further replies.

clipsymaze

Programmer
May 1, 2012
1
hi everyone.

i'm having a problem with program, the main aim of it is to display question and check against the answer the user gave, to see if its correct.

the problem i'm having is trying to check to see if the answer given is correct.

micro_watson:-
write('Micro Watson, Olympic Edition'),nl,nl,
write('Categories:'),nl,
write('1. London 2012'),nl,
write('2. Modern Olympic Games'),nl,
write('3. Ancient Olympic Games'),nl,
write('Enter your Category: '), read(X),nl,nl,
write('micro_watson: '), mode(X),
write(' '),
read(Answer),
write(Answer),
sentence(Answer).

mode(1):-
write('London 2012').
mode(2):-
write('Modern Olympic Games').
mode(3):-
write('Ancient Olympic Games').


question('Who won two track gold medal in the 2004 Summer Olympics in Athens', [adjective(two_time),noun(winner),vern(was),noun(kelly_homes)]).
question('Who won Decathlon Goal Medals in the 1980 and 1984 Summer Olympics', [adjective(two_time),noun(winner),vern(was),noun(daley_thompson)]).
question('Who won the Mens 100M at the 1980 Summer Olympics', [adjective(single_time),noun(winner),vern(was),noun(alan_wells)]).
question('In all olympic history who won the most goals medals', [verb(all_time), verb(record),noun(goldmelist),verb(was),noun(marc_spitz)]).
question('In the history of the winter olympics who was perhaps the worst sky jumper', [noun(eddie_the_eagle),adverb(really),verb(was),ady(very),noun(nondistinct)]).
question('Where are the 2012 Olympics to take place', [noun(olympics),verb( are), noun(london)]).
question('Who are the British favourites to medal in 2012',[adjective(british), noun(favourites), verb(include), noun(jess_ennis)]).

det(the).
det(a).

noun(kelly_homes).
noun(daley_thompson).
noun(alan_well).
noun(marc_spitz).
noun(eddie_the_eagle).
noun(greece).
noun(javelin).
noun(games). /*noun?*/
noun(london).
noun(olympics).
noun(jess_ennis).
noun(winner).
noun(record).
noun(favorites).
noun(nondistinct).

adj(two_time).
adj(single_time).
adj(gold_medalist).
adj(record).
adj(very).
adj(ancient).
adj(british).

adverb(really).

verb(was).
verb(all_time).
verb(record).
verb(are).
verb(include).

/*a sentence is made up of a nown phrase and a verb phrase */

sentence(Sentence,sentence(np(Noun_Phrase),vp(Verb_Phrase))):-
/* so take a sentence (first arg) and parse it into a noun phrase and a verb phase */
np(Sentence,Noun_Phrase,Rem),
vp(Rem,Verb_Phrase).

/
np([X|T],np(det(X),NP2),Rem):-
det(X),
np2(T,NP2,Rem).
np(Sentence,Parse,Rem):- np2(Sentence,Parse,Rem).
np(Sentence,np(NP,PP),Rem):-
np(Sentence,NP,Rem1),
pp(Rem1,PP,Rem).
np2([H|T],np2(noun(H)),T):- noun(H).
np2([H|T],np2(adj(H),Rest),Rem):- adj(H),np2(T,Rest,Rem). /* s
pp([H|T],pp(prep(H),Parse),Rem):-
prep(H),
np(T,Parse,Rem).

any help would be appreciated.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top