2013-03-31 47 views
1

我想學習AIML,不能明白的地方我已經錯了:AIML:沒有得到正確的答案

<aiml> 
    <category> 
     <pattern>I LIKE * ROME</pattern> 
     <template> 
      I love talking about 
      <set name="topic">rome</set> 
      too! 
      <random> 
       <li>Did you know that slaves made up 40% of the population of Ancient Rome?</li> 
       <li>Did you know the Colosseum could sit 250'000 people?</li> 
      </random> 
     </template> 
    </category> 
    <topic name="rome"> 
     <category> 
      <pattern>No *</pattern> 
      <that>Did you know that slaves made up 40% of the population of Ancient Rome?</that> 
      <template>So I've taught you something!</template> 
     </category> 
    </topic> 
</aiml> 

第一部分工作正常,如果我輸入類似:「我像羅馬的歷史「,我得到了預期的默認答案和其中一個隨機答案。但是如果他給我「奴隸」隨機答案,我說「不,我不知道那個」,他不給我「所以我教過你什麼」回答「他得到了從他的代碼別的地方的答案,但考慮到我已經設置了「主題」和<那>標籤,我已經相當具體,期望我的自定義的答案。

回答

1

<pattern>No _</pattern> 

某些地方在您的aiml文件中

0

使用<that>標籤是您的瓶頸點。對於什麼樣的圖片是值得的,我在初始模板中改變了您的回覆,並且它很有效。

關於機器人的第二個回覆。如果使用它,那麼羅馬主題中的類別將永遠不會工作,因爲<that>標籤中的40美元必須是機器人的最後一個響應。

聊天機器人的回覆中可能存在一些混淆。在話題總是變爲「羅馬」之前,爲了讓「羅馬」這個話題的模式奏效,聊天機器人不得不談論這40%的人。我只是將兩者結合起來以獲得相同的結果。

另請注意,<that>標記中的問號未放置在那裏。機器人將剝離它並存儲剩餘的結果。

<?xml version="1.0" encoding="UTF-8"?> 
<aiml> 
<category> 
    <pattern>I LIKE * ROME</pattern> 
    <template> 
    <random> 
     <li>Did you know that slaves made up 40% of the population of Ancient <set name="topic">Rome</set>?</li> 
     <li>Did you know the Colosseum in could sit 250'000 people?</li> 
    </random> 
    </template> 
</category> 
<topic name="rome"> 
    <category> 
    <pattern>No *</pattern> 
    <that>Did you know that slaves made up 40% of the population of Ancient Rome</that> 
    <template> 
     So I've taught you something! 
    </template> 
    </category> 
</topic> 
</aiml> 
0

可以在<that>標籤使用通配符(*),所以你可以匹配機器人的回答只有部分(例如,「你知道嗎,奴隸組成」)。

另請注意,該主題可以在<think>標記內設置,該標記不會顯示其內容。

我用Python AIML解釋器測試了下面的代碼。它按預期工作,但當主題名稱和內容<that><pattern>標記爲小寫時,它不起作用。

<aiml> 
<category> 
    <pattern>I LIKE * ROME</pattern> 
    <template> 
     I love talking about Rome too! 
     <think><set name="topic">ROME</set></think> 
     <random> 
      <li>Did you know that slaves made up 40 of the population of Ancient Rome?</li> 
      <li>Did you know the Colosseum could sit 250'000 people?</li> 
     </random> 
    </template> 
</category> 
<topic name="ROME"> 
    <category> 
     <pattern>NO</pattern> 
     <that>* DID YOU KNOW THAT SLAVES MADE UP *</that> 
     <template>So I've taught you something!</template> 
    </category> 
</topic> 
</aiml>