Presentation is loading. Please wait.

Presentation is loading. Please wait.

Correção dos exercícios de engenharia do conhecimento em FLORID Jacques Robin, DI-UFPE www.di.ufpe.br/~jr.

Similar presentations


Presentation on theme: "Correção dos exercícios de engenharia do conhecimento em FLORID Jacques Robin, DI-UFPE www.di.ufpe.br/~jr."— Presentation transcript:

1 Correção dos exercícios de engenharia do conhecimento em FLORID Jacques Robin, DI-UFPE

2 Estudo de caso: West é criminoso? Requisitos em Inglês 1. Para um americano, é criminoso vender armas a uma nação hostil aos EUA 2. Nono tem pelo menos um míssil 3. Nono comprou todos seus mísseis de West 4. Um míssil é um tipo de arma 5. Toda as nações inimigas dos EUA são consideradas hostis 6. West é americano 7. Nono é os EUA são nações 8. Nono é um inimigo dos EUA 0. Será que West é criminoso?

3 Estudo de caso: a terrível novela Requisitos em Inglês 1. A soap opera is a TV show whose characters include a husband, a wife and a mailman such that: 2. the wife and the mailman blackmail each other 3. everybody is either alcoholic, drug addict or gay 4. Dick is gay, Jane is alcoholic and Harry is a drug addict 5. the wife is always an alcoholic and the long-lost sister of her husband 6. the husband is always called Dick and the lover of the mailman 7. the long-lost sister of any gay is called either Jane or Cleopatra 8. Harry is the lover of every gay 9. Jane blackmails every drug addicted lover of Dick 10. soap operas are invariably terrible! 0. Who are the characters of a terrible TV show?

4 Parte comum as 2 BDDs: ontologia geral situation::entity. event::situation. action::event. happening::event. relation::situation. object::entity. physObj::object. artefact::physObj. liveBeing::physObj. org::object. quality::entity. quantity::entity. place::entity. time::entity.

5 West é criminoso? em FLORID Instâncias e Regras % Instancias (BD extensional): m1:missile. usa:nation. criminal:ethical_level. nono:nation[enemies ->> usa]. west:person [nationalities ->> usa; acts ->> transact[seller -> west; buyer -> nono; bought ->> m1]]. % Deduction rules (BD intencional): transact[seller => S; buyer => B] :- S:person, B:person. transact[seller => S; buyer => B] :- S:person, B:nation. transact[seller => S; buyer => B] :- S:nation, B:person. transact[seller => S; buyer => B] :- S:nation, B:nation. N:nation[hostile -> yes] :- N[enemies ->> usa]. P:person[ethics -> criminal] :- P[nationalities ->> usa; acts ->> transact[seller -> P; buyer -> N:nation[hostile -> yes]; bought ->> W:weapon]].

6 West é criminoso? em FLORID Hierarquia de classes e Consultas % Class hierarchy % A/ General ontology ?- % B/ Domain-specific ontology transact::action[bought =>> artefact]. person::liveBeing[nationalities =>> nation; acts =>> action; ethics => ethical_level]. weapon::artefact. missile::weapon. ethical_level::quality. nation::place[enemies =>> nation]. % Debug set-up ?- "trigger", "dump")[]. ?- sys.theOM.eqTraceOn[]. % Queries ?- sys.eval[]. ?- west[ethics -> criminal]. true. ?- west[ethics -> C]. C/criminal. true ?- west[A -> V].

7 A terrível novela em FLORID: hierarquia de classes e instâncias % Class hierarchy % A/ General ontology ?- % B/ Domain-specific ontology person::liveBeing [name => string; sex => sex; addictions =>> addictiveSub; lover =>> person; blackmails => person; sexOrient =>> sexOrient; longLostSister => person[sex => female]]. addictiveSub::artefact. org::object. tvShow::org[rating => rating]. sex::quality. sexOrient::quality. rating::quality. % Instances: male:sex. female:sex. gay:sexOrient. straight:sexOrient. terrible:rating. alcohol:addictiveSub. drugs:addictiveSub. % 4. Dick is gay, Jane is alcoholic and % Harry is a drug addict dick:person[name -> "dick"; sex -> male; sexOrient ->> gay]. jane:person[name -> "jane"; sex -> female; addictions ->> alcohol]. harry:person[name -> "harry"; sex -> male; addictions ->> drugs]. soap1:tvShow[husband -> dick; wife -> jane; mailman -> harry].

8 A terrível novela em FLORID: regras, estratificações e consultas 1 ?- sys.strat.doIt[]. ?- P:person[name -> N; sex -> S; sexOrient ->> O; addictions ->> A]. ?- P:person[name -> N; sex -> S; addictions ->> A]. ?- P:person[name -> N; sex -> S; sexOrient ->> A]. % Rules: % 3. everybody is either alcoholic, drug addict or gay P:soapChar :- P:person[addictions ->> drugs]. P:soapChar :- P:person[addictions ->> alcohol]. P:soapChar :- P:person[sexOrient ->> gay]. ?- sys.strat.doIt[]. ?- P:soapChar[name -> N]. % 7. the long-lost sister of any gay is called either Jane or Cleopatra G[longLostSister -> S] :- G:person[sexOrient ->> gay], S:person[name -> "jane"]. G[longLostSister -> S] :- G:person[sexOrient ->> gay], S:person[name -> "cleopatra"]. % 8. Harry is the lover of every gay harry[lover ->> G] :- G:person[sexOrient ->> gay]. ?- sys.strat.doIt[]. ?- P[name -> N; longLostSister -> Q[name - > S]]. ?- harry[lover ->> G[name -> N]].

9 A terrível novela em FLORID: regras, estratificações e consultas 2 % Common sense: lover relation is symmetric P:person[lover ->> Q] :- Q:person[lover ->> P]. ?- sys.strat.doIt[]. ?- dick[lover ->> G[name -> N]]. % 9. Jane blackmails every drug addicted lover of Dick jane[blackmails -> P] :- P:person[addictions ->> drugs], dick[lover ->> P]. ?- sys.strat.doIt[]. ?- jane[blackmails -> P[name -> N]]. ?- sys.strat.doIt[]. ?- S:tvShow[]. % 1. A soap opera is a TV show whose characters include % a husband, a wife and a mailman: S:soapOpera :- S:tvShow [mailman -> M:soapChar[sex -> male]; wife -> W:soapChar[sex -> female; % 2. the wife blackmails the mailman blackmails -> M; % 5a. the wife is always an alcoholic... addictions ->> alcohol]; % 5b. long-lost sister of her husband husband -> H:soapChar[longLostSister -> W; sex -> male; % 6a. the husband is always called Dick... name -> "dick"; % 6b. and the lover of the mailman lover ->> M]].

10 A terrível novela em FLORID: regras, estratificações e consultas 3 sys.strat.doIt[]. ?- S:tvShow[mailman -> M; wife -> W; husband -> H]. ?- S:soapOpera. S[cast ->> M] :- S:soapOpera[mailman -> M]. S[cast ->> W] :- S:soapOpera[wife -> W]. S[cast ->> H] :- S:soapOpera[husband -> H]. ?- sys.strat.doIt[]. ?- S:soapOpera[cast ->> C]. % 10. soap operas are invariably terrible S[rating -> terrible] :- S:soapOpera. ?- ?- ?- sys.strat.doIt[]. ?- S:tvShow[rating -> terrible]. % Final queries % 0. Who are the characters of a terrible TV show? ?- S:tvShow[rating -> terrible; cast ->> C]. ?- S:tvShow[rating -> terrible; cast ->> C; husband -> H; wife -> W; mailman -> N].


Download ppt "Correção dos exercícios de engenharia do conhecimento em FLORID Jacques Robin, DI-UFPE www.di.ufpe.br/~jr."

Similar presentations


Ads by Google