Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Powerpoint Templates PowerPoint Presentation
Download Presentation
Powerpoint Templates

Powerpoint Templates

169 Vues Download Presentation
Télécharger la présentation

Powerpoint Templates

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Using Databases in AIML by Steve Worswick Powerpoint Templates 1

  2. The problem Where does a dog live? Which animal has 2 legs? What lives on a farm and says, ‘moo’? How many legs has the animal that eats flies? Which animals say nothing? Does a cow have more legs than a chicken? … 2

  3. Setting up the database <category> <pattern>XCHECKANIMAL DOG</pattern> <template> <think> <set name="animal">dog</set> <set name="legs">4</set> <set name="lives">in a kennel</set> <set name="eats">meat</set> <set name="says">woof</set> </think> </template> </category> 3

  4. Where does a dog live? <category> <pattern>XCHECKANIMAL DOG</pattern> <template> <think> <set name="animal">dog</set> <set name="legs">4</set> <set name="lives">in a kennel</set> <set name="eats">meat</set> <set name="says">woof</set> </think> </template> </category> <category> <pattern>WHERE DOES A * LIVE</pattern> <template> <srai>XCHECKANIMAL <star index="1"/></srai> A <get name="animal"/> lives <get name="lives"/>. </template> </category> 4

  5. Where does a dog live? <category> <pattern>XCHECKANIMAL *</pattern> <template> <think> <set name="animal">UNKNOWN</set> <set name="legs">UNKNOWN</set> <set name="lives">UNKNOWN</set> <set name="eats">UNKOWN</set> <set name="says">UNKNOWN</set> </think> </template> </category> <category> <pattern>WHERE DOES A * LIVE</pattern> <template> <srai>XCHECKANIMAL <star index="1"/></srai> <condition name="animal"> <li value="UNKNOWN">I haven’t heard of a <star index="1"/>.</li> <li> A <get name="animal"/> lives <get name="lives"/>.</li> </condition> </template> </category> 5

  6. Which animal has 2 legs? <category> <pattern>WHICH ANIMAL HAS 2 LEGS</pattern> <template> <think> <set name="list">Results:<br/></set> <srai>XCHECKANIMAL DOG</srai> <srai>XCHECKMATCH 2 LEGS</srai> <srai>XCHECKANIMAL CHICKEN</srai> <srai>XCHECKMATCH 2 LEGS</srai> <srai>XCHECKANIMAL GIRAFFE</srai> <srai>XCHECKMATCH 2 LEGS</srai> <srai>XCHECKANIMAL SPIDER</srai> <srai>XCHECKMATCH 2 LEGS</srai> <srai>XCHECKANIMAL COW</srai> <srai>XCHECKMATCH 2 LEGS</srai> </think> <get name="list"/>. </template> </category> 6

  7. Which animal has 2 legs? <srai>XCHECKANIMAL DOG</srai> <srai>XCHECKMATCH 2 LEGS</srai> <srai>XCHECKANIMAL CHICKEN</srai> <srai>XCHECKMATCH2 LEGS</srai> <srai>XCHECKANIMAL GIRAFFE</srai> <srai>XCHECKMATCH2 LEGS</srai> <srai>XCHECKANIMAL SPIDER</srai> <srai>XCHECKMATCH2 LEGS</srai> <srai>XCHECKANIMAL COW</srai> <srai>XCHECKMATCH2 LEGS</srai> <category> <pattern>XCHECKMATCH 2 LEGS</pattern> <template> <condition name="legs"> <li value="2"> <set name="list"><get name="list"/><br/><get name="animal"/></set> </li> </condition> </template> </category> 7

  8. <learn> and </learn> tags <category> <pattern>WHEN I SAY * YOU SAY *</pattern> <template> If you say "<star/>" to me again, I will remember what you told me. <learn> <category> <pattern><eval><uppercase><star/></uppercase></eval></pattern> <template><eval><star index="2"/></eval></template> </category> </learn> </template> </category> Human: Jump. Bot: I can’t jump, I have no legs. Human: When I say jump, you say how high. Bot: If you say "jump" to me again, I will remember what you told me. Human: Jump. Bot: How high. 8

  9. Botcompare.aiml <category> <pattern>ARE * AND * THE SAME THING</pattern> <template> <srai> BOTCOMPARE <star/> XSPLIT <star index="2"/> </srai> <condition name="match"> <li value="YES">Yes they are.</li> <li value="NO">No, they are different.</li> </template> </category> Human: Are Homer Simpson and Marge Simpson the same thing? Bot: No, they are different. Human: Are Bart Simpson and Bart Simpson the same thing? Bot: Yes they are. www.square-bear.co.uk/aiml 9

  10. Botcompare.aiml <category> <pattern>BOTCOMPARISON</pattern> <template> <learn> <category> <pattern> <eval><uppercase>BOTCHECK <get name="comparevalue1"/> </uppercase></eval> </pattern> <template> <think> <set name="match">YES</set> </think> </template> </category> </learn> <srai>botcheck <get name="comparevalue2"/></srai> <srai>botremovecomparison</srai> </template> </category> 10

  11. Which animal has 2 legs? <category> <pattern>XSCANANIMALDATABASE</pattern> <template> <think> <set name="list">Results:<br/></set> <srai>XCHECKANIMAL DOG</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKANIMAL CHICKEN</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKANIMAL GIRAFFE</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKANIMAL SPIDER</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKANIMAL COW</srai> <srai>XCHECKMATCH</srai> </think> <get name="list"/>. </template> </category> 11

  12. Which animal has 2 legs? <category> <pattern>WHICH ANIMAL HAS * LEGS</pattern> <template> <think> <set name="searchfor"><star/></set> <learn> <category> <pattern>XCHECKMATCH</pattern> <template> <srai>BOTCOMPARE<get name="legs"/> XSPLIT <get name="searchfor"/></srai> <condition name="match"> <li value="YES"><set name="list"><get name="list"/><br/> <get name="animal"/></set></li> </condition> </template> </category> </learn> </think> <srai>XSCANANIMALDATABASE</srai> </template> </category> 12

  13. What lives on a farm and says ‘moo’? <category> <pattern>WHAT LIVES * AND SAYS *</pattern> <template> <think> <set name="searchfor"><star/> <star index="2"/></set> <learn> <category> <pattern>XCHECKMATCH</pattern> <template> <srai>BOTCOMPARE <get name="lives"/> <get name="says"/> XSPLIT <get name="searchfor"/></srai> <condition name="match"> <li value="YES"><set name="list"><get name="list"/><br/> <get name="animal"/></set></li> </condition> </template> </category> </learn> </think> <srai>XSCANANIMALDATABASE</srai> </template> </category> 13

  14. How many legs has the animal that eats flies? <category> <pattern>HOW MANY LEGS HAS THE ANIMAL THAT EATS *</pattern> <template> <think> <set name="searchfor"><star/></set> <learn> <category> <pattern>XCHECKMATCH</pattern> <template> <srai>BOTCOMPARE<get name="eats"/> XSPLIT <get name="searchfor"/></srai> <condition name="match"> <li value="YES"><set name="list"><get name="list"/><br/> A <get name="animal"/> eats <get name="eats"/> and has <get name="legs"/> legs. </set></li> </condition> </template> </category> </learn> </think> <srai>XSCANANIMALDATABASE</srai> </template> </category> 14

  15. Which animals say nothing? <category> <pattern>WHICH ANIMALS SAY *</pattern> <template> <think> <set name="searchfor"><star/></set> <learn> <category> <pattern>XCHECKMATCH</pattern> <template> <srai>BOTCOMPARE <get name="says"/> XSPLIT <get name="searchfor"/></srai> <condition name="match"> <li value="YES"><set name="list"><get name="list"/><br/> <get name="animal"/></set></li> </condition> </template> </category> </learn> </think> <srai>XSCANANIMALDATABASE</srai> </template> </category> 15

  16. Does a cow have more legs than a chicken? <category> <pattern>DOES A * HAVE MORE LEGS THAN A *</pattern> <template> <think> <srai>XCHECKANIMAL <star/></srai> <set name="legs1"><get name="legs"/></set> <srai>XCHECKANIMAL <star index="2"/></srai> <set name="legs2"><get name="legs"/></set> <set name="checklegs"><get name="legs1"/> <get name="legs2"/></set> </think> <condition name="checklegs"> <li value="2 2">They both have 2 legs.</li> <li value="2 4">A <star index="2"/> has more legs.</li> <li value="2 8">A <star index="2"/> has 4 times as many legs.</li> <li value="4 2">A <star/> has more legs.</li> <li value="4 4">They both have 4 legs.</li> <li value="4 8">A <star index="2"/> has twice as many legs.</li> <li value="8 2">A <star index="2"/> has 4 times as many legs.</li> <li value="8 4">A <star/> has twice as many legs.</li> <li value="8 8">They both have 8 legs.</li> </condition> </template> </category> 16

  17. Does a cow have more legs than a chicken? <li value="UNKNOWN UNKNOWN">Sorry but I have never heard of either of those animals.</li> <li value="2 UNKNOWN">Well, I have not heard of a <star index="2"/>. However, a <star/> only has 2 legs and so I guess a <star index="2"/> has more legs.</li> <li value="4 UNKNOWN">Well, I have not heard of a <star index="2"/>. However, a <star/> has 4 legs and so I guess a <star/> has more legs.</li> <li value="8 UNKNOWN">Well, I have not heard of a <star index="2"/>. However, a <star/> has 8 legs and so I guess a <star/> has more legs.</li> <li value="UNKNOWN 2">Well, I have not heard of a <star/>. However, a <star index="2"/> only has 2 legs and so I guess a <star/> has more legs.</li> <li value="UNKNOWN 4">Well, I have not heard of a <star/>. However, a <star index="2"/> has 4 legs and so I guess a <star index="2"/> has more legs.</li> <li value="UNKNOWN 8">Well, I have not heard of a <star/>. However, a <star index="2"/> has 8 legs and so I guess a <star/> has more legs.</li> <li>The one that runs fastest probably has more legs.</li> 17

  18. What if there is no unique index? <category> <pattern>XCHECKANIMAL DOG</pattern> <template> <think> <set name="animal">dog</set> <set name="legs">4</set> <set name="lives">in a kennel</set> <set name="eats">meat</set> <set name="says">woof</set> </think> </template> </category> 18

  19. What if there is no unique index? <category> <pattern>XCHECKEMPLOYEE JANE</pattern> <template> <think> <set name="firstname">Jane</set> <set name="surname">Peterson</set> <set name="dept">Sales</set> <set name="employed">1992</set> </think> </template> </category> 19

  20. What if there is no unique index? <category> <pattern>XCHECKEMPLOYEE 1</pattern> <template> <think> <set name="firstname">Jane</set> <set name="surname">Peterson</set> <set name="dept">Sales</set> <set name="employed">1992</set> </think> </template> </category> 20

  21. What if there is no unique index? <category> <pattern>XSCANDATABASE</pattern> <template> <think> <set name="list">Results:<br/></set> <srai>XCHECKEMPLOYEE 1</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKEMPLOYEE 2</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKEMPLOYEE 3</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKEMPLOYEE 4</srai> <srai>XCHECKMATCH</srai> <srai>XCHECKEMPLOYEE 5</srai> <srai>XCHECKMATCH</srai> </think> <get name="list"/>. </template> </category> 21

  22. What use is it? (facts and figures) 22

  23. What use is it? (word knowledge database) A database with 2,000 records takes approximately 10 seconds to search 23

  24. What use is it? (word knowledge database) • <category> • <pattern>XCHECKWORD CARROT</pattern> • <template> • <think> • <set name="word">carrot</set> • <set name="syl">2</set> • <set name="plural">carrots</set> • <set name="size">C</set> • <set name="does">grows underground</set> • <set name="use">helps you see in the dark</set> • … • <set name="whatisit">vegetable</set> • <set name="wordhas">a stalk</set> • <set name="volume">0</set> • </think> • </template> • </category> • <category> • <pattern>XP2S CARROTS</pattern> • <template> • <think><set name="singular">carrot</set></think> • </template> • </category> 24

  25. Any questions? steve@mitsuku.com www.mitsuku.com www.square-bear.co.uk/aiml 25