日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > ChatGpt >内容正文

ChatGpt

AIML应答机器人(一)aiml简介

發布時間:2023/12/31 ChatGpt 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AIML应答机器人(一)aiml简介 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章列表

AIML應答機器人(一)aiml簡介

AIML應答機器人(二)java實現


想做一款和上圖一樣的自動應答機器人嗎,跟著博客,咱們一步步實現,現在開始第一個內容,簡單了解下什么是AIML語言

AIML

????????AIML:人工智能標記語言(Artificial Intelligence Markup Language)

????????AIML(人工智能標記語言)是一種XML兼容的語言,很容易學習,并且可以開始定制艾爾博特(Alicebot)或分分鐘創建一個scratch機器人。AIML最重要的單元有:
????????開始和結束一個AIML文檔的標簽(tag)
????????標志著一個艾爾博特知識庫(Alicebot's knowledge base)的“知識單元”標簽<</font>類別>
????????用于包含匹配用戶給艾爾博特(an Alicebot)機器人可以說或鍵入字符的一個簡單模式(simple pattern)<<font face="宋體">模式>
????????包含對用戶輸入(user input)的響應<<font face="宋體">模板>
AIML文件中經常發現有20個左右或附加多個標簽(tags),創建自己所謂“自定義謂詞(custom predicates)”是可能的。現在,AIML Primer提供一個AIML初學者指南。免費Alice機器人人工智能標記語言(The free Alice機器人 AIML)包括一個約41000分類的知識庫(knowledge base)


舉例:

<?xml version="1.0" encoding="UTF-8"?> <aiml><category><pattern>今天天氣挺好*</pattern><template>是嗎?我這里下雨了。要是沒下雨,我就出去玩了!</template></category><category><pattern>_天氣_</pattern><template>url:http://wap.baidu.com/s?word=<star index="1" />天氣</template></category><category><pattern>_百度下_</pattern><template>url:http://wap.baidu.com/s?word=<star index="2" /></template></category></aiml>

????以上片段再加上html的支持,就可以實現查詢天氣,與百度內容

????下面簡單介紹下,每個標簽的用法,含義,如果大家心急,可以先跳過這一步,直接去第二篇博客進行系統搭建了。

標簽

1、基本標簽

????<aiml>:定義在AIML文件的開頭和結尾。 它包含在版本和編碼屬性的版本和編碼信息。
????<category>:定義unit ofknowledge中Alicebot的知識庫。每個類別包含在一個句子的形式,用戶輸入可以是一個斷言,問題和感嘆號等用戶的輸入可以包含通配符的字符,如*和_。用<category>標簽必須有<pattern>和<template>標記。
????<pattern>:定義圖案什么用戶可輸入匹配到Alicebot。
????<template> :定義一個Alicebot的用戶的輸入的響應。<template>標簽可以保存數據,可以調用另一個程序,能夠給條件答案或委托給其他類別。

2、<*> :用于匹配通配符*character(s)在<pattern>標簽。

???

<category><pattern> A * is a *.</pattern><template>When a <starindex="1"/> is not a <star index="2"/>?</template></category>


3、<random> :用于獲取隨機響應。

4、<li> :用來表示多個響應。


<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern>HI</pattern><template><random><li> Hello! </li><li> Hi! Nice to meet you! </li></random></template> </aiml>5、<set> :使用在AIML變量設定值。

6、<get> :用于獲取存儲在AIML變量的值。

<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern>I am*</pattern><template>Hello <set name="username"><star/>! </set></template> </category> <category> <pattern>GoodNight</pattern><template>Hi <getname="username"/> Thanks for the conversation!</template> </category> </aiml>
7、<that> :在AIML用于應對基于上下文。表示先前機器人說的話。
<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern>WHAT ABOUTMOVIES</pattern><template>Do you like comedymovies</template> </category><category><pattern>YES</pattern><that>Do you like comedymovies</that><template>Nice, I like comedy moviestoo.</template></category><category><pattern>NO</pattern><that>Do you like comedymovies</that><template>Ok! But I like comedymovies.</template></category>? </aiml>
Human: What about movies?
Robot: Do you like comedy movies?
Human: No
Robot: Ok! But I like comedy movies.

?

8、<topic> :用于AIML存儲上下文,這樣以后可以談話基于這一背景下進行。
?<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern>LET DISCUSSMOVIES</pattern><template>Yes <setname="topic">movies</set></template> </category><topic name="movies"><category><pattern> *</pattern><template>Watching good movierefreshes our minds.</template></category><category><pattern> I LIKE WATCHING COMEDY!</pattern><template>I like comedy moviestoo.</template></category></topic></aiml>Human: let discuss movies
Robot: Yes movies
Human: Comedy movies are nice to watch
Robot: Watching good movie refreshes ourminds.
Human: I like watching comedy
Robot: I too like watching comedy.
?

9、<think>:用于AIML存儲變量不通知用戶。
<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern>My name is*</pattern><template>Hello!<think><setname="username"> <star/></set></think></template> </category> <category><pattern>Byeee</pattern><template>Hi <getname="username"/> Thanks for the conversation!</template> </category> </aiml>Human: My name is Mahesh
Robot: Hello!
Human: Byeee
Robot: Hi Mahesh Thanks for theconversation!

?

10、<condition>:類似的切換在編程語言語句。 它有助于ALICE來匹配輸入作出響應。
?<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1" encoding="UTF-8"?><category><pattern> HOW ARE YOUFEELING TODAY </pattern><template><think><setname="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>Human: How are you feeling today
Robot: I am happy!

?

11、<srai>:多用途標簽,用來調用其它/匹配的類別。(符號縮減、分而治之、同義詞分辨率、關鍵詞檢測)
?<?xml version="1.0"encoding="UTF-8"?><aiml version="1.0.1"encoding="UTF-8"?><category><pattern> WHO ISALBERT EINSTEIN </pattern><template>Albert Einstein was agerman physicist.</template></category><category><pattern> WHO ISIsaac NEWTON </pattern><template>Isaac Newton was a englishphysicist and mathematician.</template></category><category><pattern>DO YOU KNOWWHO * 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>DevelopmentCenter!</template></category><category><pattern>INDUSTRY</pattern><template><srai>FACTORY</srai></template></category><category><pattern>SCHOOL</pattern><template>School is an importantinstitution 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>Human: I love going to school daily.
Robot: School is an important institutionin a child's life.
Human: I like my school.
Robot: School is an important institutionin a child's life.
?
12、<upcase>xiaoxie</upcase>元素用來把xiaoxie轉換成大寫形式:XIAOXIE
13、<system><system>元素表示調用系統函數,例如:<system>date</system>表示取系統當前日期。
14、<sentence>元素用來格式化句子,比如:<sentence>this is some kind ofsentence test.</sentence>可以格式化成:This is some kind of sentence test.即把句子首字母大寫。
15、<pattern>表示匹配模式,里面的內容必須大寫,可以有星號* 或下劃線_,但必須空格隔開,星號表示匹配所有,任意情況;下劃線的意義跟星號一樣,除了不能匹配字典里面Z后面的字母。
16、<lowcase></lowcase>表示把中間的內容變成小寫,對應的是<upcase>把內容變成大寫
?????????? 中文無效。
17、<learenfilename=”xxx.aiml”>元素表示讓機器人學習某個aiml文件。
18、<if>元素,判斷元素,有以下形式:<if name="topic"value="cars"></if> <if name="topic"contains="cars"></if> <if name="topic"exists="true"></if>
19、<formal>元素,用來格式化輸出,例如:<formal>jon baer</formal>那么回復將被格式化成首字母大寫輸出:Jon Baer,對中文無效。
20、<NUM/>元素,匹配數字
21、約束匹配模式

<category><pattern that="你好">你好啊</pattern><template><random>

????????????<li>你好,我們剛剛說過一遍了。</li>

????????????<li>你好,客氣啥!</li>

????</random>

????</template>

</category>

上述示例中,并不會直接命中”你好啊“,而是在上一次是匹配的”你好“,當又匹配了”你好啊“才會命中上述category,即上次和當前次的連續匹配

總結

以上是生活随笔為你收集整理的AIML应答机器人(一)aiml简介的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。