/* * 08146 1718 * Artifical Intelligence ACW2 * By: John Allison *//* * Top level chatbot */agent:- %Chatbot creation. %agent perceives the environment – agent takes action against environment percive(Percepts), action(Percepts)./* * Percive */percive(Percepts):- %Intro & Input write(‘Hello, I am Santas Little Helper!’),nl, write(‘I am here to help you decide what present to get your loved ones.’),nl, write(‘what present to get your loved ones this time of year’),nl, nl, %empty line write(‘Please describe the person and their hobby’),nl, read_input(Percepts). %user input/* * Action */action(Percepts):- %Parse Input to Output %Parse, list traversal sentence(Percepts), %Parse = sentence(Noun_Phrase,Verb_Phrase), %Set Parse input to Noun Phrase & Verb Phrase %VP = vp(verb(Verb),Rest), %Pass verb from verb_phrase %sentence(Noun_Phrase,Verb_Phrase), %Check against sentence rules %Write output write(‘You should get ‘),Output,write(‘ for your loved one.’),nl./* * Dictionary */%detdet(a).det(an).%adjectiveadj(good).adj(lonely).adj(elderly).adj(teenage).adj(manual).adj(very).%verbverb(thrives).verb(likes).verb(loves).%prepositionprep(with).%nounnoun(problem).noun(young).noun(boy).noun(girl).noun(challenge).noun(conversation).noun(father).noun(golf).noun(student).noun(party).noun(person).noun(book)./* * Synonyms * synonym/1 */%Lovessynonym(loves,likes,adores,passion,fondness,devoition).%Problemsynonym(problem,challenge,puzzle,brainteaser,conundrum).%Manualsynonym(manual,physical).%goodsynonym(good,great,excellent,satisfying,supurb,nice,neat).%lonelysynonym(lonely,alone,lonesome,reclusive,isolated,desolate).%studentsynonym(student,graduate,pupil,scholar,undergraduate,apprentice).%partysynonym(party,celebration,ball,festivity,gala,get_together).%teenagesynonym(teenage,teenager).%booksynonym(book,novel,paperback,textbook).%fathersynonym(father,dad,daddy,male_parent)./* * Vocabulary * sentence/2 */%a very young boy loves a manual problemsentence( noun_phrase(det(a),np2(adj(very),np2(young),np2(noun(boy)))), verb_phrase(verb(loves),np(det(a),np2(adj(manual),np2(noun(problem)))))).%a teenage girl loves a challengesentence( noun_phrase(det(a),np2(adj(teenage),np2(noun(girl)))), verb_phrase(verb(loves),np(det(a),np2(noun(challenge))))).%an elderly grandfather likes a good booksentence( noun_phrase(det(an),np2(adj(elderly),np2(noun(grandfather)))), verb_phrase(verb(likes),np(det(a),np2(adj(good),np2(noun(book)))))).%a lonely person thrives with a conversationsentence( noun_phrase(det(a),np2(adj(lonely),np2(noun(person)))), verb_phrase(verb(thrives),np(prep(with),det(a),np2(noun(conversation))))).%a young father loves golfsentence( noun_phrase(det(a),np2(adj(young),np2(noun(father)))), verb_phrase(verb(loves),np(np2(golf)))).%a teenage student loves a partysentence( noun_phrase(det(a),np2(adj(teenage),np2(noun(student)))), verb_phrase(verb(loves),np(det(a),np2(noun(party))))).%does there need to be a nondefined value? TODO/* * Language parsing from Input * sentence/2 */%S->NP VP & S->VPsentence(Sentence,sentence(np(Noun_Phrase),vp(Verb_Phrase))):- np(Sentence,Noun_Phrase,Rem), vp(Rem,Verb_Phrase).%NP->Det NP2np(Extra|Tail,np(det(Extra),NP2),Rem):- det(Extra), np2(Tail,NP2,Rem).%NP->NP2np(Sentence,Parse,Rem):- np2(Sentence,Parse,Rem).%NP->NP PPnp(Sentence,np(NP,PP),Rem):- np(Sentence,NP,Rem1), pp(Rem1,PP,Rem).%NP2->Nounnp2(Head|Tail,np2(noun(Head)),Tail):- noun(Head).%NP2->Adj NP2np2(Head|Tail,np2(adj(Head),Rest),Rem):- adj(Head), np2(Tail,Rest,Rem).%PP->Prep NPpp(Head|Tail,pp(prep(Head),Parse),Rem):- prep(Head), np(Tail,Parse,Rem).%VP->Verbvp(Head|,(verb(Head))):- verb(Head).%VP->Verb NPvp(Head|Tail,vp(vnp(Head),Parse),Rem):- vnp(Head), vp(Tail,Parse,Rem).%VP->VP PPvp(Head|Tail,vp(vp_pp(Head),Parse),Rem):- vp_pp(Head), vp(Tail,Parse,Rem)./* * Recommendations on Input * present/4 * Based on present(,subject(),verb().object(). */%a very young boy loves a manual problempresent(construction_kit,subject(very,young,boy),verb(loves),object(manual,problem)).%a teenage girl loves a challengepresent(raspberry_pi,subject(teenage,girl),verb(loves),object(challenge)).%an elderly grandfather likes a good bookpresent(breif_history_of_time,subject(elderly,grandfather),verb(likes),object(good,book)).%a lonely person thrives with a conversationpresent(the_internet,subject,(lonely,person),object(conversation)).%a young father loves golfpresent(a_golfing_sweater,subject(young,father),verb(loves),object(golf)).%a teenage student loves a partypresent(money,subject(teenage,student),verb(loves),object(party)).

x

Hi!
I'm James!

Would you like to get a custom essay? How about receiving a customized one?

Check it out