AIML condition标记
<condition>
标签类似于编程语言中的switch
语句。 它有助于ALICE响应匹配的输入。
语法
<condition name = "variable-name" value = "variable-value"/>
例如,请考虑以下对话。
Human: How are you feeling today Robot: I am happy!
在这里,我们将happy
存放为ALICE的状态,看看它是如何响应“I am happy!”。
示例
在D:/software/ab/bots/test/aiml
目录中创建一个文件:condition.aiml
,并在D:/software/ab/bots/test/aimlif
目录中创建一个文件:condition.aiml.csv
。
文件:condition.aiml
<?xml version = "1.0" encoding = "UTF-8"?> <aiml version = "1.0.1" encoding = "UTF-8"?> <category> <pattern> HOW ARE YOU FEELING TODAY </pattern> <template> <think><set name = "state"> happy</set></think> <condition name = "state" value = "happy"> I am happy! </condition> <condition name = "state" value = "sad"> I am sad! </condition> </template> </category> </aiml>
文件:condition.aiml.csv -
0,HOW ARE YOU FEELING TODAY,*,*, <think> <set name = "state"> happy</set> </think> <condition name = "state" value = "happy">I am happy!</condition> <condition name = "state" value = "sad">I am sad!</condition>,condition.aiml
执行程序
打开命令提示符。 进入目录:D:/software/ab 并键入以下命令 -
java -cp lib/Ab.jar Main bot = test action = chat trace = false
执行上面示例代码,得到以下结果 -
Human: How are you feeling today Robot: I am happy!
上一篇:AIML think标签
下一篇:没有了
关注微信小程序
扫描二维码
程序员编程王