Aiml-srai-tag
AIML-<srai>タグ
*<srai>* タグは多目的タグです。 このタグにより、AIMLは同じテンプレートの異なるターゲットを定義できます。
構文
<srai> pattern </srai>
以下は、 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.
さて、 what if の質問は
Human: DO YOU KNOW WHO Albert Einstein IS?
Human: DO YOU KNOW WHO Isaac Newton IS?
ここでは、 <srai&gt タグが機能します。 ユーザーのパターンをテンプレートとして使用できます。
ステップ1:カテゴリーを作成する
<category>
<pattern>WHO IS ALBERT EINSTEIN?</pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON? </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
ステップ2:<srai&gtタグを使用して汎用カテゴリを作成する
<category>
<pattern>DO YOU KNOW WHO * IS?</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
例
*C> ab>ボット>テスト> aiml* 内にsrai.aimlを作成し、 *C> ab>ボット>テスト> aimlif* ディレクトリ内にsrai.aiml.csvを作成します。
srai.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern> WHO IS ALBERT EINSTEIN </pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
<category>
<pattern>DO YOU KNOW WHO * IS</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
</aiml>
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,*,*,<srai>WHO IS <star/></srai>,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!を返信することが期待されています。ユーザーが文の先頭で *Bye と言ったときはいつでも。
ここで<srai&gtタグを機能させましょう。
ステップ1:カテゴリーを作成する
<category>
<pattern>BYE</pattern>
<template>Good Bye!</template>
</category>
ステップ2:<srai&gtタグを使用して汎用カテゴリを作成する
<category>
<pattern>BYE *</pattern>
<template>
<srai>BYE</srai>
</template>
</category>
例
*C> ab> bots> test> aiml* およびsrai.aiml.csv内のsrai.aimlを *C> ab> bots> test> aimlif* ディレクトリ内で更新します。
srai.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern> WHO IS ALBERT EINSTEIN </pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
<category>
<pattern>DO YOU KNOW WHO *IS</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
<category>
<pattern>BYE</pattern>
<template>Good Bye!</template>
</category>
<category>
<pattern>BYE* </pattern>
<template>
<srai>BYE</srai>
</template>
</category>
</aiml>
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,*,*,<srai>WHO IS <star/></srai>,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,<srai>BYE</srai>,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!
ここで、ユーザーが Factory または Industry と言ったときはいつでも、ロボットは* Development Center!*と返信することが期待されています。
ここで動作するように <srai> タグを配置しましょう。
ステップ1:カテゴリーを作成する
<category>
<pattern>FACTORY</pattern>
<template>Development Center!</template>
</category>
ステップ2:<srai>タグを使用して汎用カテゴリを作成する
<category>
<pattern>INDUSTRY</pattern>
<template>
<srai>FACTORY</srai>
</template>
</category>
例
*C> ab> bots> test> aiml* およびsrai.aiml.csv内のsrai.aimlを *C> ab> bots> test> aimlif* ディレクトリ内で更新します。
srai.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern> WHO IS ALBERT EINSTEIN </pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
<category>
<pattern>DO YOU KNOW WHO *IS</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
<category>
<pattern>BYE</pattern>
<template>Good Bye!</template>
</category>
<category>
<pattern>BYE* </pattern>
<template>
<srai>BYE</srai>
</template>
</category>
<category>
<pattern>FACTORY</pattern>
<template>Development Center!</template>
</category>
<category>
<pattern>INDUSTRY</pattern>
<template>
<srai>FACTORY</srai>
</template>
</category>
</aiml>
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,*,*,<srai>WHO IS <star/></srai>,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,<srai>BYE</srai>,srai.aiml
0,FACTORY,*,*,Development Center!,srai.aiml
0,INDUSTRY,*,*,<srai>FACTORY</srai>,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* を使用すると、ユーザーが特定のキーワード(「学校」など)を入力したときに、文中の「学校」がどこにあっても、簡単な応答を返すことができます。
たとえば、次の会話を考えます。
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.
ここで、ロボットは標準メッセージ*「学校は子供の生活の中で重要な機関です。」*に返信することが期待されます。*ユーザーが文に*学校*を持っているときはいつでも。
ここで動作するように <srai> タグを配置しましょう。 ここではワイルドカードを使用します。
ステップ1:カテゴリーを作成する
<category>
<pattern>SCHOOL</pattern>
<template>School is an important institution in a child's life.</template>
</category>
ステップ2:<srai&gtタグを使用して一般的なカテゴリを作成する
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
例
*C> ab> bots> test> aiml* およびsrai.aiml.csv内のsrai.aimlを *C> ab> bots> test> aimlif* ディレクトリ内で更新します。
srai.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern> WHO IS ALBERT EINSTEIN </pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
<category>
<pattern>DO YOU KNOW WHO *IS</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
<category>
<pattern>BYE</pattern>
<template>Good Bye!</template>
</category>
<category>
<pattern>BYE* </pattern>
<template>
<srai>BYE</srai>
</template>
</category>
<category>
<pattern>FACTORY</pattern>
<template>Development Center!</template>
</category>
<category>
<pattern>INDUSTRY</pattern>
<template>
<srai>FACTORY</srai>
</template>
</category>
<category>
<pattern>SCHOOL</pattern>
<template>School is an important institution in a child's life.</template>
</category>
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
</aiml>
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,*,*,<srai>WHO IS <star/></srai>,srai.aiml
0,BYE,*,*,Good Bye!,srai.aiml
0,BYE *,*,*,<srai>BYE</srai>,srai.aiml
0,FACTORY,*,*,Development Center!,srai.aiml
0,INDUSTRY,*,*,<srai>FACTORY</srai>,srai.aiml
0,SCHOOL,*,*,School is an important institution in a child's life.,srai.aiml
0,_ SCHOOL,*,*,<srai>SCHOOL</srai>,srai.aiml
0,SCHOOL *,*,*,<srai>SCHOOL</srai>,srai.aiml
0,_ SCHOOL *,*,*,<srai>SCHOOL</srai>,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.