Hand Click over Web Adress

Download Report

Transcript Hand Click over Web Adress

Using Databases in AIML
by Steve Worswick
Powerpoint Templates
Page 1
1
The problem
Animal
Legs
Lives
Eats
Says
dog
4
in a kennel
meat
woof
chicken
2
on a farm
corn
cluck
giraffe
4
in Africa
leaves
nothing
spider
8
in a web
flies
nothing
cow
4
on a farm
grass
moo
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?
…
Powerpoint Templates
Page 2
2
Setting up the database
Animal
Legs
Lives
Eats
Says
dog
4
in a kennel
meat
woof
chicken
2
on a farm
corn
cluck
giraffe
4
in Africa
leaves
nothing
spider
8
in a web
flies
nothing
cow
4
on a farm
grass
moo
<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>
Powerpoint Templates
</category>
Page 3
3
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>
Powerpoint Templates
Page 4
4
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>
Powerpoint Templates
Page
</category>
5
5
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>
Powerpoint Templates
Animal
Legs
dog
4
chicken
2
giraffe
4
spider
8
cow
4
Page 6
6
Which animal has 2 legs?
<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>
Animal
Legs
dog
4
chicken
2
giraffe
4
spider
8
cow
4
<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>
Powerpoint Templates
Page 7
7
<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.
Powerpoint Templates
Page 8
Bot: How high.
8
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
Powerpoint Templates
Page 9
9
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>
Powerpoint Templates
</category>
Page 10
10
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>
Powerpoint Templates
Animal
Legs
dog
4
chicken
2
giraffe
4
spider
8
cow
4
Page 11
11
Which animal has 2 legs?
<category>
<pattern>WHICH ANIMAL HAS * LEGS</pattern>
<template>
<think>
<set name="searchfor"><star/></set>
Animal
Legs
dog
4
chicken
2
giraffe
4
<learn>
spider
8
<category>
cow
4
<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>
Powerpoint
</category>
Templates
Page 12
12
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>
Animal Lives
Says
</condition>
</template>
dog
in a kennel woof
</category>
chicken on a farm
cluck
</learn>
</think>
<srai>XSCANANIMALDATABASE</srai>
</template>
Powerpoint
</category>
giraffe
in Africa
nothing
spider
in a web
nothing
on a farm
moo
Page 13
Templatescow
13
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>
Animal
Legs Eats
</template>
dog
4
meat
</category>
</learn>
chicken 2
corn
</think>
<srai>XSCANANIMALDATABASE</srai>
</template>
Powerpoint
</category>
Templates
giraffe
4
leaves
spider
8
flies
cow
4
Page 14
grass
14
Which animals say nothing?
<category>
<pattern>WHICH ANIMALS SAY *</pattern>
<template>
<think>
<set name="searchfor"><star/></set>
Animal
Says
dog
woof
chicken
cluck
giraffe
nothing
<learn>
spider
nothing
<category>
<pattern>XCHECKMATCH</pattern>
cow
moo
<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>
Powerpoint
Templates
Page 15
15
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>
Powerpoint Templates
</category>
Page
16
16
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>
Powerpoint Templates
Page 17
17
What if there is
no unique index?
Animal
Legs
Lives
Eats
Says
dog
4
in a kennel
meat
woof
chicken
2
on a farm
corn
cluck
giraffe
4
in Africa
leaves
nothing
spider
8
in a web
flies
nothing
cow
4
on a farm
grass
moo
<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>
Powerpoint Templates
</category>
Page 18
18
What if there is
no unique index?
First name
Surname
Department
Employed since
Jane
Peterson
Sales
1992
Michael
Brown
Mail Room
2003
Jane
Hargreaves
Marketing
1996
Simon
Brown
Sales
2001
Paula
Harrison
Legal
1992
<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>
Powerpoint Templates
Page 19
19
What if there is
no unique index?
Index
First name
Surname
Department
Employed since
1
Jane
Peterson
Sales
1992
2
Michael
Brown
Mail Room
2003
3
Jane
Smith
Marketing
1996
4
Simon
Brown
Sales
2001
5
Paula
Harrison
Legal
1992
<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>
Powerpoint Templates
Page 20
20
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>
Powerpoint Templates
Page 21
21
What use is it?
(facts and figures)
Country
Capital
Currency
Area
Language
Population
USA
Washington DC
Dollar
3,718,691
English
307,212,123
India
New Delhi
Rupee
1,269,338
Hindi
1,166,079,217
Animal
chicken
cow
Letter
A
B
Baby
chick
calf
Boy’s name
Andrew
Brian
Male
rooster
bull
Girl’s name
Anne
Brenda
Female
hen
cow
City
Athens
Berlin
Legs
2
4
Country
Algeria
Belgium
Sound
cluck
moo
Fruit
Apple
Banana
Eats
corn
grass
Vegetable
Asparagus
Bean
Lives
coop
farm
Animal
Anteater
Bear
Gives us
eggs
meat
Job
Actor
Banker
Noun
brood
herd
Sport
Archery
Baseball
Description
galline
Airship
Bicycle
Powerpoint
Templates
bovine
Transport
Page 22
22
What use is it?
(word knowledge database)
Word
Syllables
Plural
Size
Does
carrot
2
carrots
C
grows
underground
Use
Speed
Length
Spell
Colour
lets you see NONE
in the dark
6
CARROT
orange
What is it
Rhyme
Synonym
Where
Made From
vegetable
parrot
root
vegetable
in a grocers
plant matter
Has
Volume
a stalk
0
A database with 2,000 records takes
approximately 10 seconds to search
Powerpoint Templates
Page 23
23
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>
Powerpoint Templates
</template>
</category>
Page 24
24
Any questions?
[email protected]
www.mitsuku.com
www.square-bear.co.uk/aiml
Powerpoint Templates
Page 25
25