Sie sind auf Seite 1von 23

4/6/2009

Workshop on Verbot
By:AliMadooei

WHAT IS VERBOT?
Verbot is a combination of Artificial
I t lli
Intelligence,
N t l Language
Natural
L
P
Processing,
i
and creativity that allows you create an
engaging virtual personality that can
perform many tasks.

4/6/2009

WHAT IS VERBOT?
Chatterbot?!
ExpertSystem?!

Tool(Shell)

Available Resources
VerbotWikiat
htt //
http://www.verbots.com/wiki/Main_Page
b t
/ iki/M i P
PDFManualsat
http://www.verbots.com/wiki/Manual:Verbot_PDF
Verbotforumsat
http://www.verbots.com/forums/index.php

4/6/2009

Tutorial 1
1)RunVerbotEditor
2) Save the blank knowledgebase as myWorkshop.vkb
2)SavetheblankknowledgebaseasmyWorkshop.vkb
3)Makeyourfirstrule (RuleName:wtz_ur_name)
4)OutputText:Whatisyourname?
5)InputText:start
6)Testknowledgebase

Tutorial 1 - Continued
7)Makeanewchildrule
Rule Name: wtz ur gender
RuleName:wtz_ur_gender
8)OutputText:Whatisyourgender?
9)InputText:mynameis[name]
10)Editoutputto:
OutputText:Hello[name]
Whatisyourgender?
11)Testknowledgebase

4/6/2009

Tutorial 1 - Outcomes

TorunVerbotEditor
Tosaveaknowledgebase(*.vkb)
MakeaRulewithinputandoutput
MakeachildRule
HowtodefineVariables putthemin[]
Totestaknowledgebase

Tutorial 2
1)editthelastinput
I
InputText:mynameis[name]
tT t
i [
]
InputText:itis[name]
InputText:callme[name]
2)Testknowledgebase
(whatifIsayitsAli)

4/6/2009

Tutorial 2 - Continued
3)Createasynonymfile
)
y
y
4)Synonymname:isphrases:is&s
5)Saveitasworkshopsyn.vsn
6)Addthisfiletoyourresourcefile
7)Changetheinputto
InputText:myname(is)[name]
Input Text: it(is) [name]
InputText:it(is)
InputText:callme[name]
8)Testtheknowledgebase

Tutorial 2 - Continued
9)Makeanewchild
R l N
RuleName:male
l
RuleName:female
10)EdittheRule:male
InputText:Iammale
p
,
[
]
OutputText:Well,Mr.[name]
WhatisyourstudentID?

4/6/2009

Tutorial 2 - Continued
11)Edittherule:female
I
InputText:Iamfemale
tT t I
f
l
OutputText:Well,Ms.[name]
WhatisyourstudentID?
12)Testknowledgebase

Tutorial 2 - Outcomes
Tocreatesynonyms(*.vsn)
UseofVerbotresourcefiles
Howtousesynonym
putthesynonymnamein()

4/6/2009

Tutorial 3
1)Openyoursynonymfile
2) Make a new synonym
2)Makeanewsynonym
(name:malephrases:male&boy&man&masculine)
3)Makeanewsynonym
(name:femalephrases:female&girl&woman)
4)Savethesynonymfile
5)Editsomeinputs
)
p
RuleName:maleInputText:(male)
RuleName:femaleInputText:(female)
6)Testknowledgebase

Tutorial 3 - Continued
7)Makeanewrule
RuleName:student_ID
R
l N
t d t ID
InputText:[studentID]
OutputText:Youinformationisasfollows:
Name:[name]
StudentID:[studentID]

8) Add virtual child


8)Addvirtualchild
(rulestudent_id asachildofrule:male&rule:female)

9)Testknowledgebase

4/6/2009

Tutorial 3 - Continued
Makesomeenhancements!Usingspecialinputs
10)Makeanewrule
RuleName:_startup
InputText:_startup
OutputText:WelcometoAIRSIGWorkshoponVerbot.
HereisAPIIT.
IamVerbot.Shallwestartbyyourname?

Tutorial 3 - Continued
12)Make3childrulesforrule:_startup
RuleName:yes
R
l N
RuleName:no
RuleName:else

13)Openyoursynonymfile
14)Makenewsynonyms
((Name:yesphrases:yes&yap&yeah&ok&okay&ofcourse
h
&
&
h& k& k & f
&y&positive&sure)
(Name:nophrases:no&none&non&negative&n&nope
&noway&not)

4/6/2009

Tutorial 3 - Continued
15)Savethesynonymfile
16)Edityourrulesinputs
RuleName:yesInputText:(yes)
RuleName:noInputText:(no)
RuleName:elseInputText:*

17) Make an output for rule: yes


17)Makeanoutputforrule:yes
OutputText:<sendstart >

18)Testknowledgebase

Tutorial 3 - Outcomes
TouseVirtualchild
Whatarethedifferenceofvirtualchildandchild?

Tousespecialinputtags
_startup

_bored*(default)

HowtomakeVerbotfireaRulewithout
Input.
Input
use<sendinput>whereinputisthephraseyou
havegivenastheinputofthedesiredrule

4/6/2009

Tutorial 4
1)Makeanoutputforrule:no
OutputText:Wellthenbye!<exit >

2)Testtheknowledgebase
3)Makeanoutputforrule:else
OutputText:I'msorrybutIreallyneedayesorno.

4)Makealoop
4)
M k l
b ddi
byaddingvirtualchildbetween
i t l hild b t
yes no else
5)Testtheknowledgebase

Tutorial 4 - Continued
Makesomeenhancements!UsingInternal
Variables

6)Edittheoutputforrule:_startup
OutputText:WelcometoAIRSIGWorkshoponVerbot.
Todayis[_dayofweek],[_date],andthetimeis[_time].
Here is APIIT
HereisAPIIT.
IamVerbot.Shallwestartbyyourname?

7)Testknowledgebase

10

4/6/2009

Tutorial 4 - Continued
Makesomeenhancements!UsingCode
Modules
Objective:
BuildyourVerbotinawaytocheckthetimeand
basedonthetimemakeitsgreetingexpressions:
(5amto12pm)>goodmorning
(12pmto4pm)>goodafternoon
(4pmto10pm)>goodevening

Tutorial 4 - Continued
8) Open Code Modules
9) Save
S
a module
d l as
mycodes.vcm
10) Rename the module
name to mycodes

11

4/6/2009

Tutorial 4 - Continued
11)Createnewfunctionandnameitgreeting(No parameter/returntype:string)
int hour=DateTime
hour DateTime .Now.Hour;
Now Hour
stringgreet="";
if(hour>=5&&hour<12){
greet="Goodmorning";
}
elseif(hour>=12&&hour<16){
greet="Goodafternoon";
}
elseif(hour>=16&&hour<22){
greet="Goodevening";
}
else{
greet="Hello";
}
returngreet;

9 ThisisC#programminglanguage.
9 CodingusingDateTimein.NET
framework.Check:
http://msdn.microsoft.com/en
us/library/ms973825.aspx

Tutorial 4 - Continued

12

4/6/2009

Tutorial 4 - Continued
12)CompiletheCodes
13)OpenshowcodesandseehowitwillbelooklikeinC#
environment
14)Savethefileandcloseit
15)Addmycodes.vcmtoyourresourcefile
16)Edittheoutputforrule:_startup
OutputText:<?csharp Console.Write(mycodes.greeting());?>
WelcometoAIRSIGWorkshoponVerbot.
Todayis[_dayofweek],[_date],andthetimeis[_time].
y [_ y
] [_
]
[_
]
HereisAPIIT.
IamVerbot.Shallwestartbyyourname?
17)Testknowledgebase
18)ClosetheeditorandruntheVerbotplayer
19)RuntheknowledgebaseandTesttheapplication

Tutorial 4 - Outcome
HowdoyoucloseaVerbot?
Note:
Note: <exit>
exit and
and <quit>
quit behaveexactlythesamemaking
behave exactly the same making
theminterchangeable.
Makingloop usingVirtualchild
Isitcountercontrolled repetitionorsentinelcontrolled
repetition?
UsingInternalVariables
[_
[ time][
] [_time24][
] [_date][
] [_month][
] [_dayofmonth][
y
] [_yyear]
]
[_dayofweek]
UsingCodeModuletointerpretC#codes(*.vcm)
RunaknowledgebaseinVerbotPlayer

13

4/6/2009

Tutorial 5
Case Study: APIIT should be pronounced as /apit/
Enhance your Verbot with correct pronunciation!
1) Run Verbot Editor and
open myWorkshop.vkb
2) Open Replacement Profile
Editor

Tutorial 5 - Continued
3)Addbelowoutputs

4)Saveitasworkshoprep.vrp
)
p p p
5)Addworkshoprep.vrptoyourresourcefile
6)ClosetheeditorandruntheVerbotplayer
7)Runtheknowledgebaseandtesttheapplication

14

4/6/2009

Tutorial 5 - Outcome
UsingReplacementProfile(*.vrp)

Tutorial 6
Enhancement!Saveyourusersinformation
in a text file
inatextfile
1)RunVerboteditor,gotoyour
knowledgebaseandopenmycodes.vcm
2)Createanewfunctionandnameit:
save (Parameter:stringname,stringid/returntype:string)
(P
t
ti
t i id/ t
t
ti )
9 UsingC#programminglanguage.
9 CodingusingStreamWriter class.Check:
http://msdn.microsoft.com/enus/library/6ka1wd3w.aspx

15

4/6/2009

Tutorial 6 - Continued
Randomrnd =newRandom();
int num=rnd.Next(100,9999);
stringfilename=name+num.ToString()+".txt";
try{{
try
using(System.IO.StreamWriter sw =newSystem.IO.StreamWriter(filename)){
sw.Write("Thefileisgeneratedon:");
sw.WriteLine(DateTime.Now);
sw.WriteLine("");
sw.Write("Givenname:");
sw.WriteLine(name);
sw.Write("StudentID:");
sw.WriteLine(id);
sw.WriteLine("");
sw.WriteLine("AIRSIG APIIT CopyRight @2009");
sw.Flush();
sw.Close();
}
}catch(Exceptione){
Console.WriteLine("ProblemSavingFile:"+e.Message);
}
returnfilename;

Tutorial 6 - Continued

16

4/6/2009

Tutorial 6 - Continued
3)Compilethecodes
4) Save the file and close it
4)Savethefileandcloseit
5)Makeanewrule
RuleName:txt_file
InputText:save
OutputText:
Y
Yourfilenameis:<?csharp
fil
i
? h
vars["myFile"]=
[" Fil "]
mycodes.save(vars["name"],vars["studentID"]);
?>[myFile].
Doyouwanttoopenthefile?

Tutorial 6 - Continued
6)Make2childrulesfortherule:txt_file
Rule Name: no Input Text: (no)
RuleName:noInputText:(no)
RuleName:open_file InputText:(yes)
7)makeanoutputforrule:open_file (Followthepicture)

17

4/6/2009

Tutorial 6 - Continued
8)Makeanoutputforrule:no
OutputText:Okay.Youcanopenitlater.Justrememberitisnamed
[myFile].
<printtext It'savailableatc:documents>

9)Linktherule:student_id torule:txt_file (edittheoutput)


RuleName:student_ID
InputText:[studentID]
Output Text: You information is as follows:
OutputText:Youinformationisasfollows:
name:[name]
StudentID:[studentid]
<agent.pause 350>
<sendsave>

Tutorial 6 - Continued
10)Toavoidwronginputs,copythechildruleelse
and past it as a child for rule txt
andpastitasachildforrule
txt_file
file
11)Makealoopbyaddingvirtualchild(betweenyes
no else)
12)ClosetheeditorandruntheVerbotplayer
13)Runtheknowledgebaseandtesttheapplication

18

4/6/2009

Tutorial 6 - Outcomes
UsingembeddedC#codes
SimplywriteyourC#withina<?csharp ... ?>tag,
andit'llbeexecutedwhentherulefires.
Eample:<?csharp Console.Write("Helloworld!"); ?>

FireaNulloutput<>
Call and Run applications by Command option
CallandRunapplicationsbyCommandoption
UsingVerbotTags <printtext text>
UsingMS.Agent Tags<agent.pause 360>

Tutorial 7
Makeageneralloopfortheprogram
1)RunVerboteditor,openyourknowledgebaseandcreatenewrulebasedonthebelowframe
Rule Name: exit
RuleName:exit
InputText:exit
OutputText:Doyouwanttoexit?
ChildRuleName:else
InputText:*
OutputText:I'msorrybutIreallyneedayesorno.
ChildRuleName:no
InputText:(no)
OutputText:Wellthenlet'sdoitagain!
ll h l ' d i
i !
<agent.pause 350)
<sendstart>
ChildRuleName:yes
InputText:(yes)
OutputText: Itwasnicetomeetyou!
<exit>

19

4/6/2009

Tutorial 7 - Continued
2)Linktherule:txt_file torule:exit(byeditting theoutput)
RuleName:txt_file
InputText:save
OutputText:Yourfilenameis:<?csharp vars["myFile"]=
mycodes.save(vars["name"],vars["studentID"]);?>[myFile].
Doyouwanttoopenthefile?
RuleName:no
InputText:(no)
OutputText:Okay.Youcanopenitlater.Justrememberitisnamed[myFile].
<printtext It'savailableatc:documents>
<agent.pause 360>
<sendexit>>
<sendexit
Rule Name: open file
RuleName:open_file
InputText:(yes)
OutputText:<>
<agent.pause 360>
<sendexit>
Cmd:[myFile]
RuleName:else
InputText:*
OutputText:I'msorrybutIreallyneedayesorno.

Tutorial 7 - Continued
3)ClosetheeditorandruntheVerbotplayer
4) R th k
4)Runtheknowledgebaseandtesttheapplication
l d b
d t t th
li ti

20

4/6/2009

Tutorial 8
Validation!Namecanonlycontaincharacters.
AnadvancedfeatureofusingVariableCapturesin
Verbotallowsyoutorestrictwhatthevariablecapture
willmatchtousingRegularExpressions.
9 Tousethisadvancedfeature,simplyscriptanormal
variableinyourinput:[varname]Then,torestrictmatching,
placean"="beforetheclosesquarebracketandafterthe
equalssignyouwillputtheregularexpressionsyntaxyou
wanttolimitthevariableto.

Tutorial 8 - Continued
9 Forexample,letssayyouwantavariablethatonly
accepts digits this is how you would define the variable
acceptsdigits,thisishowyouwoulddefinethevariable
captureintheinput:
[varname=\b"\d+"\b]
TounderstandanduseRegularExpressiongoto:
http://www.dotnetcoders.com/default.aspx?PID=regOver

21

4/6/2009

Tutorial 8 - Continued
1)Openyourknowledgebaseineditorandgotorule
wtz
wtz_ur_gender
ur genderthenedittheinputasindicated
then edit the input as indicated
below
RuleName:wtz_ur_gender
InputText:myname(is)[name=\b"[AZaz]+"\b]
InputText:it(is)[name=\b"[AZaz]+"\b]
InputText:callme[name=\b"[AZaz]+"\b]
InputText:[name=\b"[AZaz]+"\b]
InputText:*[name=\b"[AZaz]+"\b]

Tutorial 8 - Continued
2)Addachildruleelsetocatchtheerrors
RuleName:else
Rule
Name: else
InputText:*
OutputText:Thatdoesn'tsoundlikeanametome.
Doyouliketotryagain?
Ifyoudon'twantmetoknowyourrealname,youcaninput
anyothername.

3)Makeavirtualchildbetweenruleelseandrule
3)
M k
i t l hild b t
l l
d l
wtz_ur_gender toformaloop
4)ClosetheeditorandruntheVerbotplayer
5)Runtheknowledgebaseandtesttheapplication

22

4/6/2009

Assignment
This program has some bugs that you can find
and
d fix
fi it by
b just
j t using
i
th features
the
f t
we
explained in this session.

23

Das könnte Ihnen auch gefallen