multipurpose its implementation document 20021169 김계현 im lab

Download Multipurpose ITS Implementation Document 20021169 김계현 IM Lab

If you can't read please download the document

Upload: meredith-davidson

Post on 08-Jan-2018

227 views

Category:

Documents


0 download

DESCRIPTION

Completed Modules

TRANSCRIPT

Multipurpose ITS Implementation Document IM Lab. System Overview Completed Modules Main class ITS static void main(String[] args) static void learn(KnowledgeBase kb, KnowledgeGenerator kg) static void teach(KnowledgeBase kb, KnowledgeGenerator kg, Planner planner) Knowledge Base Knowledge Base (contd) class KnowledgeBase Concept addConcept(String name); Relation addRelation(String name); Fact addFact(String name, String[] premises, String[] conjunction, int n); Rule addRule(Vector basis, String[] premises, String[][] terms, String conclusion, String[] cterms); Fact ask(String relation, String[] terms); void execute(); void print(); Fact Fact (contd) class Concept class Relation void addRule(Rule rule); void addFact(Fact fact); void focusOn(); boolean isTrue(Fact fact); boolean isAlreadyDerived(Fact fact); boolean isContradicted(Fact fact); void on(IEngine ie, Fact fact); boolean equals(Object item); void print(Logger log, int depth); Fact (contd) class Fact void print(Logger log, int depth); Fact negates(); boolean equals(Object item); void on(IEngine ie); Rule Rule (contd) class Rule void print(Logger log, int depth); void on(IEngine ie, Fact fact); Inference Engine Inference Engine (contd) class IEngine void setQuery(Fact query) void infer() Vector getLies() Vector getContradictions() void accept(Fact accepted) void contradict(Fact contradicted) void addOn() Inference Engine (contd) switch-on node breadth-first search . Concept : Fact on Fact : Concept Relation on Relation : relation Rule on Rule : derive Fact on , on node . Inference Engine (contd) public void on(IEngine ie, Fact fact) // fact print // fact concept substitutes add // i premise match // premise negation fact // substitutes fact concept add // premise term variable constant concept add // add // add concept check add // premise loop // premise on , conclusion false . // , negative premise check . fact derive premise on ... // variable substitute rule check , // iteration n // substitute variable rule match // substitute rule match // loopVariable[i] : i variable substitute concept iteration // ex> loopVairable[0], [1], [2] 3, 4, 5 , substitutes[0], [1], [2] 3, 4, 5 concept . // true , iteration fact // rule match premise , premise true fact // premise variable/concept index // test // index usedConcept substitutes concept // test print // test . isTrue isAlreadyDerived fact . // Concept-relation network , fact // substitute premise true // conclusion fact // match rule , rule derive fact print // iteration concept // variable // n 10 1 // 1188 , = 1189 , = 1190 // 1 0 , 10 1 = 1200 . Knowledge Generator Knowledge Generator (contd) class KnowledgeGenerator Vector conjunctConcepts(Vector conjuncted, String added) Fact[] addFacts(KnowledgeBase kb, Vector premises) Vector premiseZero(Vector conjuncted, String relation, boolean isNegated); Vector premiseN(Vector conjuncted, String rconj, String relation, String[] tconj, Vector[] targets, boolean isNegated); Vector buildRule(Vector conditions, Vector matched, Vector unmatched); Rule[] addRule(KnowledgeBase kb, Vector vectoredRules); int setN(Vector conjuncted); String negates(String relation); int readInt(); Natural Language Recognizer NLR (contd) ({LETTER}|{DIGIT}|_)* { else if(yytext().equals("if") | yytext().equals("If")) tokenID = sym.IF; else if(yytext().equals("but") | yytext().equals("But") | yytext().equals("However") | yytext().equals("however") | yytext().equals("even though") | yytext().equals("Even though") | yytext().equals("Nevertheless") | yytext().equals("nevertheless")) tokenID = sym.BUT; } NLR (contd) paragraph ::= statementList statementList ::= statementList statement | statement statement ::= facts:fs endmark {: parser.kg.addFacts(parser.kb, fs); :} | rule:r endmark {: parser.kg.addRule(parser.kb, r); :} | error endmark NLR (contd) concept ::= concept ID | ID facts ::= facts ANDOP fact | fact conjunctedConcepts ::= conjunctedConcepts COMMA concept NLR (contd) fact ::= conjunctedConcepts IS concept | conjunctedConcepts IS concept OF conjunctedConcepts | conjunctedConcepts DO ID conjunctedConcepts rule ::= IF facts THEN facts | IF facts THEN facts ELSE facts Planner class Planner Fact[] addQueries(KnowledgeBase kb, Vector premises); Example C:\...\code>java ITS (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 2 West and is American. East is criminal & East did sell sugar to China. sugar is food. China is hostile. Scud, DaePoDong and Patriot are missile & Axe and Knife, Sasimi are weapon. Nono is enemy of America. West did sell Scud to Nono. if _x is missile then _x is weapon. if _x is enemy of America then _x is hostile. if _x did sell _y to _z & _x is American & _y is weapon & _z is hostile then _x is criminal. Example (contd) *** Contents of Knowledge Base *** Facts: West is American ... Scud is missile Axe is weapon East did sell sugar to China sugar is food China is hostile Nono is enemy of America West did sell Scud to Nono Rules: ( missile ) => weapon ( enemy ) => hostile ( sell American weapon hostile ) => criminal (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 1 Example (contd) (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 3 West is criminal. On Concept: West On Relation: West is American On Relation: West did sell Scud to Nono ... Iteration 0: Scud is missile *** On ConnectPremise *** ( missile ) => weapon *** Newly Derived Fact *** Scud is weapon Example (contd) On Concept: America Newly Added: Nono is enemy of America Iteration 0: Nono is enemy of America *** On ConnectPremise *** ( enemy ) => hostile *** Newly Derived Fact *** Nono is hostile ... Example (contd) Iteration 0: West did sell Scud to Nono West is American Scud is weapon Nono is hostile *** On ConnectPremise *** ( sell American weapon hostile ) => criminal *** Newly Derived Fact *** West is criminal ... On Relation: West is criminal ** TrulyAccepted ** West is criminal ALL TRUE (0: load, 1: save, 2: learn, 3: teach, 4: exit) ? 4 C:\...\code>