2016-03-29 32 views
1

我注意到,我們可以用沃森的EntityType提取time reference來自用戶的輸入,如:使用實體類型爲沃森對話框形狀可變

<folder label="Invite Time"> 
       <output id="output_invite_time"> 
        <prompt> 
         <item>What time is your meeting?</item> 
        </prompt> 
        <getUserInput> 
         <input> 
          <grammar> 
           <item>$ (DATE_TIME_RANGE)={var-invite_time}</item> 
          </grammar> 
          <action varName="var-invite_time" operator="SET_TO">{var-invite_time.value:FROM_TIME}</action> 
          <goto ref="output_invite_date"/> 
         </input> 
         <output> 
          <prompt> 
           <item>I'll need a valid time to continue.</item> 
          </prompt> 
          <goto ref="output_invite_time"/> 
         </output> 
        </getUserInput> 
       </output> 
      </folder> 

我試圖找出如何使用其他(支持? )EntityTypes像通用,位置,金額等,但結果有時是意想不到的。例如,「位於美國科羅拉多州丹佛市的好房子」對於位置實體的結果「很好」;或者在日期不正確的日期中指定「昨天」。

我簡化對話框的文件如下:

<?xml version="1.0" encoding="UTF-8"?> 
 
<dialog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd"> 
 
    <flow> 
 
     <folder label="Main" id="Main"> 
 
      <output id="start"> 
 
       <prompt selectionType="RANDOM"> 
 
        <item>DIALOG START - asking for user input</item> 
 
       </prompt> 
 
       <goto ref="processUserInput_start"/> 
 
      </output> 
 
      <getUserInput id="processUserInput_start"> 
 
       <search ref="library_supported-intents"/> 
 
       <default> 
 
        <output> 
 
         <prompt selectionType="RANDOM"> 
 
          <item>I am sorry, I did not understand your intents. Please choose intent1.</item> 
 
         </prompt> 
 
        </output> 
 
       </default> 
 
      </getUserInput> 
 
     </folder> 
 
     <folder label="Library" id="Library"> 
 
      <folder label="Main Input" id="library_supported-intents"> 
 
       <input> 
 
        <grammar> 
 
         <item>intent1</item> 
 
        </grammar> 
 
        <output> 
 
         <prompt selectionType="RANDOM"> 
 
          <item>OK. Executing intent 1</item> 
 
         </prompt> 
 
         <goto ref="intent1-detail-generic"/> 
 
        </output> 
 
       </input> 
 
      </folder> 
 
      <folder label="Intent 1 Input Generic" id="library_intent1-generic"> 
 
       <output id="intent1-detail-generic"> 
 
        <prompt> 
 
         <item>Please specify generic</item> 
 
        </prompt> 
 
        <getUserInput> 
 
         <search ref="library_supported-intents"/> 
 
         <input> 
 
          <grammar> 
 
           <item>$ (ZIPCODE)={var-param_generic}</item> 
 
          </grammar> 
 
          <action varName="var-param_generic" operator="SET_TO">{var-param_generic.value:main}</action> 
 
          <goto ref="intent1-detail-location"/> 
 
         </input> 
 
         <output> 
 
          <prompt> 
 
           <item>I'll need a valid generic to continue.</item> 
 
          </prompt> 
 
          <goto ref="intent1-detail-generic"/> 
 
         </output> 
 
        </getUserInput> 
 
       </output> 
 
      </folder> 
 
      <folder label="Intent 1 Input Location" id="library_intent1-location"> 
 
       <output id="intent1-detail-location"> 
 
        <prompt> 
 
         <item>Please specify Location</item> 
 
        </prompt> 
 
        <getUserInput> 
 
         <search ref="library_supported-intents"/> 
 
         <input> 
 
          <grammar> 
 
           <item>$ (LOCATION)={var-param_location}</item> 
 
          </grammar> 
 
          <action varName="var-param_location" operator="SET_TO">{var-param_location.source}</action> 
 
          <goto ref="intent1-detail-amount"/> 
 
         </input> 
 
         <output> 
 
          <prompt> 
 
           <item>I'll need a valid location to continue.</item> 
 
          </prompt> 
 
          <goto ref="intent1-detail-location"/> 
 
         </output> 
 
        </getUserInput> 
 
       </output> 
 
      </folder> 
 
      <folder label="Intent 1 Input Location" id="library_intent1-amount"> 
 
       <output id="intent1-detail-amount"> 
 
        <prompt> 
 
         <item>Please specify Amount</item> 
 
        </prompt> 
 
        <getUserInput> 
 
         <search ref="library_supported-intents"/> 
 
         <input> 
 
          <grammar> 
 
           <item>$ (AMOUNT)={var-param_amount}</item> 
 
          </grammar> 
 
          <action varName="var-param_amount" operator="SET_TO">{var-param_amount.value:main}</action> 
 
          <goto ref="intent1-detail-time"/> 
 
         </input> 
 
         <output> 
 
          <prompt> 
 
           <item>I'll need a valid amount to continue.</item> 
 
          </prompt> 
 
          <goto ref="intent1-detail-amount"/> 
 
         </output> 
 
        </getUserInput> 
 
       </output> 
 
      </folder> 
 
      <folder label="Intent 1 Input Time" id="library_intent1-time"> 
 
       <output id="intent1-detail-time"> 
 
        <prompt> 
 
         <item>Please specify time</item> 
 
        </prompt> 
 
        <getUserInput> 
 
         <search ref="library_supported-intents"/> 
 
         <input> 
 
          <grammar> 
 
           <item>$ (DATE_TIME_RANGE)={var-param_time}</item> 
 
          </grammar> 
 
          <action varName="var-param_time" operator="SET_TO">{var-param_time.value:FROM_TIME}</action> 
 
          <goto ref="intent1-detail-date"/> 
 
         </input> 
 
         <output> 
 
          <prompt> 
 
           <item>I'll need a valid time to continue.</item> 
 
          </prompt> 
 
          <goto ref="intent1-detail-time"/> 
 
         </output> 
 
        </getUserInput> 
 
       </output> 
 
      </folder> 
 
      <folder label="Intent 1 Input Date" id="library_intent1-date"> 
 
       <output id="intent1-detail-date"> 
 
        <prompt> 
 
         <item>Please specify date</item> 
 
        </prompt> 
 
        <getUserInput> 
 
         <search ref="library_supported-intents"/> 
 
         <input> 
 
          <grammar> 
 
           <item>$ (DATE_TIME_RANGE)={var-param_date}</item> 
 
          </grammar> 
 
          <action varName="var-param_date" operator="SET_TO">{var-param_date.value:FROM_DATE}</action> 
 
          <output> 
 
           <prompt> 
 
            <item>You've specified {var-param_time} on {var-param_date}.</item> 
 
           </prompt> 
 
          </output> 
 
          <goto ref="processUserInput_start"/> 
 
         </input> 
 
         <output> 
 
          <prompt> 
 
           <item>I'll need a valid date to continue.</item> 
 
          </prompt> 
 
          <goto ref="intent1-detail-date"/> 
 
         </output> 
 
        </getUserInput> 
 
       </output> 
 
      </folder> 
 
     </folder> 
 
     <folder label="Concepts" id="Concepts"></folder> 
 
    </flow> 
 
    <entities> 
 
     <entity name="ZIPCODE" entityType="GENERIC"> 
 
      <value name="10024" value="10024"/> 
 
      <value name="07928" value="07928"/> 
 
      <value name="95118" value="95118"/> 
 
      <value name="95120" value="95120"/> 
 
      <value name="uszipcode" value="!^[0-9]{5}$"/> 
 
      <entityRules></entityRules> 
 
     </entity> 
 
    </entities> 
 
    <variables> 
 
     <var_folder name="Home"> 
 
      <var name="IntentClass" type="TEXT"/> 
 
      <var name="Class1" type="TEXT"/> 
 
      <var name="Class1_Confidence" type="NUMBER" initValue="0" description="Confidence score for Class1 from NL classifier"/> 
 
      <var name="var-param_date" type="TEXT" description="Date object"/> 
 
      <var name="var-param_time" type="TEXT" description="Time object"/> 
 
      <var name="var-param_generic" type="TEXT" description="Generic Object"/> 
 
      <var name="var-param_location" type="TEXT" description="Location Object"/> 
 
      <var name="var-param_amount" type="TEXT" description="Amount Object"/> 
 
     </var_folder> 
 
    </variables> 
 
</dialog>

我不知道如果我用它給the sample tutorial以正確的方式只提到{ProfVar.value:main} or {ProfVar.value:name}。我在官方文檔中找不到FROM_TIMEFROM_DATEDATE_TIME_RANGE

支持哪些實體類型以及如何正確提取Watson Dialog中的實體特定信息?

+0

我不知道支持哪些類型。但這裏有一些提示。對於AMOUNT,創建變量類型的var-param_amount INTEGER。另請注意,您的規則是$(AMOUNT)嘗試添加$(AMOUNT),它應該可以工作。空間可能會被考慮。 對於這個位置,如果你的句子是「在科羅拉多州丹佛市的好房子」,你的規則應該是$ *(LOCATION)= {var-param_location} – Dudi

+0

For Amount,它可以將「five」解釋爲「5」 - 但是「$ *(LOCATION)= {var-param_location}'帶有 {var-param_location.value:main}'爲空。 – totoro

回答

0

我想弄清楚如何使用其他(支持?)EntityTypes像通用,位置,金額等,但結果有時是意想不到的。例如,「位於美國科羅拉多州丹佛市的好房子」對於位置實體的結果「很好」;或者在日期不正確的日期中指定「昨天」。

「Nice」是法國的城市。所以它給出了正確的迴應。

問題是Dialogs實體提取是非常基本的。從你的樣本:

$ (LOCATION)={var-param_location} 

這將找到第一個實體,並停止尋找。爲了演示這個限制,可以說你想在用戶響應中獲得三個可能的位置。

$ (LOCATION)={var-param_location} 
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2} 
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2} 
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2} (LOCATION)={var-param_location3} 
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2} (LOCATION)={var-param_location3} 
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2 * (LOCATION)={var-param_location3} 
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2 * (LOCATION)={var-param_location3} 

正如你所看到的,它會開始越來越混亂。這實際上只適用於你期望一個實體或顯式數量的實體被返回的地方。

如果您想獲得更準確的實體/關鍵字提取,請先將它發送到AlchemyAPI之類的東西。讓API返回關鍵字/實體,然後使用它們。