我注意到我们可以使用 Watson EntityType 从用户输入中提取时间参考,例如:
<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,如Generic、Location、Amount等。但结果有时出乎意料。例如,位置实体的“科罗拉多州丹佛的好房子”结果为“好”;或为日期指定“昨天”会导致日期不正确。
我的简化对话框文件如下:
<?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>
鉴于仅提到的示例教程,我不确定我是否以正确的方式使用它{ProfVar.value:main} or {ProfVar.value:name}
。我在官方文档中找不到FROM_TIME
and FROM_DATE
for 。DATE_TIME_RANGE
支持哪些实体类型,如何在 Watson Dialog 中正确提取实体特定信息?