📜  AIML-标签

📅  最后修改于: 2020-11-10 04:21:42             🧑  作者: Mango


标签是多用途标签。该标签使AIML可以为同一模板定义不同的目标。

句法

以下是与srai相关的常用术语-

  • 符号还原

  • 分而治之

  • 同义词解析

  • 关键字检测

符号还原

符号缩减技术用于简化模式。它有助于减少带有简单模式的复杂语法模式。

例如,考虑以下对话。

Human: Who was Albert Einstein?
Robot: Albert Einstein was a German physicist.
Human: Who was Isaac Newton?
Robot: Isaac Newton was a English physicist and mathematician.

现在,如果提出问题怎么办

Human: DO YOU KNOW WHO Albert Einstein IS?
Human: DO YOU KNOW WHO Isaac Newton IS?

在这里, 标签起作用。它可以将用户模式作为模板。

步骤1:建立类别


   WHO IS ALBERT EINSTEIN?
   



    WHO IS Isaac NEWTON? 
   

步骤2:使用标记创建通用类别


   DO YOU KNOW WHO * IS?
   
   
   

C> ab> bots> test> aiml中创建srai.aiml,并在C> ab> bots> test> aimlif目录中创建srai.aiml.csv

srai.aiml



   
       WHO IS ALBERT EINSTEIN 
      
   
   
   
       WHO IS Isaac NEWTON 
      
   
   
   
      DO YOU KNOW WHO * IS
      
   

star.aiml.csv

0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml
0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml
0,DO YOU KNOW WHO * IS,*,*,WHO IS ,srai.aiml

执行程序

打开命令提示符。转到C> ab>并键入以下命令-

java -cp lib/Ab.jar Main bot = test action = chat trace = false

验证结果

您将看到以下输出-

Human: Do you know who Albert Einstein is
Robot: Albert Einstein was a German physicist.

分而治之

分而治之用于重覆子句以做出完整的答复。它有助于减少定义多个类别。

例如,考虑进行以下对话。

Human: Bye
Robot: GoodBye!
Human: Bye Alice!
Robot: GoodBye!

现在,这里的机器人有望回复GoodBye!每当用户在句子开头说“再见”时。

让我们在这里使用

步骤1:建立类别


   BYE
   

步骤2:使用标记创建通用类别


   BYE *
   
   
   

C> ab> bots> test> aiml中更新srai.aiml,在C> ab> bots> test> aimlif目录中更新srai.aiml.csv

srai.aiml



   
       WHO IS ALBERT EINSTEIN 
      
   
 
   
       WHO IS Isaac NEWTON 
      
   
   
   
      DO YOU KNOW WHO * IS
      
   
   
   
      BYE
      
   
   
   
      BYE *
      
   
   

star.aiml.csv

0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml
0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml
0,DO YOU KNOW WHO * IS,*,*,WHO IS ,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,BYE,srai.aiml

执行程序

打开命令提示符。转到C> ab>并键入以下命令-

java -cp lib/Ab.jar Main bot = test action = chat trace = false

验证结果

您将看到以下输出-

Human: Bye
Robot: GoodBye!
Human: Bye Alice!
Robot: GoodBye!

同义词解析

同义词是具有相似含义的词。机器人应以相同的方式回答类似的单词。

例如,考虑以下对话。

Human: Factory
Robot: Development Center!
Human: Industry
Robot: Development Center!

现在,这里的机器人有望回复开发中心!每当用户说出工厂工业

让我们在这里使用标签。

步骤1:建立类别


   FACTORY
   

步骤2:使用标签创建通用类别


   INDUSTRY
   
   
   

C> ab> bots> test> aiml中更新srai.aiml,在C> ab> bots> test> aimlif目录中更新srai.aiml.csv

srai.aiml



   
       WHO IS ALBERT EINSTEIN 
      
   
   
   
       WHO IS Isaac NEWTON 
      
   
   
   
      DO YOU KNOW WHO * IS
      
   
   
   
      BYE
      
   
   
   
      BYE *
      
   
   
   
      FACTORY
      
   
   
   
      INDUSTRY
      
   
   

star.aiml.csv

0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml
0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml
0,DO YOU KNOW WHO * IS,*,*,WHO IS ,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,BYE,srai.aiml
0,FACTORY,*,*,Development Center!,srai.aiml
0,INDUSTRY,*,*,FACTORY,srai.aiml

执行程序

打开命令提示符。转到C> ab>并键入以下命令-

java -cp lib/Ab.jar Main bot = test action = chat trace = false

验证结果

您将看到以下输出-

Human: Factory
Robot: Development Center!
Human: Industry
Robot: Development Center!

关键字检测

使用srai ,当用户键入特定的关键字(例如School)时,无论句子中的“ school”在哪里,我们都可以返回简单的响应。

例如,考虑以下对话。

Human: I love going to school daily.
Robot: School is an important institution in a child's life.
Human: I like my school.
Robot: School is an important institution in a child's life.

在这里,希望机器人回复标准消息“学校是孩子生命中的重要机构”。每当用户在句子中上学时。

让我们在这里使用标签。我们将在此处使用通配符。

步骤1:建立类别


   SCHOOL
   

步骤2:使用标记创建通用类别


   _ SCHOOL
   



   _ SCHOOL
   



   SCHOOL *
   



   _ SCHOOL *
   

C> ab> bots> test> aiml中更新srai.aiml,在C> ab> bots> test> aimlif目录中更新srai.aiml.csv

srai.aiml



   
       WHO IS ALBERT EINSTEIN 
      
   
   
   
       WHO IS Isaac NEWTON 
      
   
   
   
      DO YOU KNOW WHO * IS
      
   
   
   
      BYE
      
   
   
   
      BYE *
      
   
   
   
      FACTORY
      
   
   
   
      INDUSTRY
      
   
   
   
      SCHOOL
      
     
   
   
      _ SCHOOL
      
   
   
   
      _ SCHOOL
      
   
   
   
      SCHOOL *
      
   
   
   
      _ SCHOOL *
      
   
   

star.aiml.csv

0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml
0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml
0,DO YOU KNOW WHO * IS,*,*,WHO IS ,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,BYE,srai.aiml
0,FACTORY,*,*,Development Center!,srai.aiml
0,INDUSTRY,*,*,FACTORY,srai.aiml
0,SCHOOL,*,*,School is an important institution in a child's life.,srai.aiml
0,_ SCHOOL,*,*,SCHOOL,srai.aiml
0,SCHOOL *,*,*,SCHOOL,srai.aiml
0,_ SCHOOL *,*,*,SCHOOL,srai.aiml

执行程序

打开命令提示符。转到C> ab>并键入以下命令-

java -cp lib/Ab.jar Main bot = test action = chat trace = false

验证结果

您将看到以下输出-

Human: I love going to school daily.
Robot: School is an important institution in a child's life.
Human: I like my school.
Robot: School is an important institution in a child's life.