Watson Dialog Dynamic Data variable input/output

2019-07-26 18:56发布

I'm trying to build a simple dialog that the user will write: "My name is Joe", and I want the Dialog to set a userName variable to "Joe". I found this example, but the response is always empty string.

<folder label="Main">

        <output>
            <prompt selectionType="RANDOM">
                <item>Hello, What's your name?
                </item>
            </prompt>
        </output>
        <input id="input_2530402">
            <grammar>
                <item>My name is</item>
                <item>my name is (DYNAMIC_DATA)={userName}</item>
                <item>mine is (DYNAMIC_DATA)={userName}</item>
                <item>(DYNAMIC_DATA)={userName} </item>
                <item>(DYNAMIC_DATA)={userName} GiveName</item>
            </grammar>
            <action varName="userName" operator="SET_TO">{userName.source}</action>
            <action varName="Defaulted_Previous" operator="SET_TO_NO"/>
            <output>
                <prompt>
                    <item>Hi {userName}!</item>
                </prompt>
            </output>
        </input>
    </folder>

Variable definition:

<variables>
    <var_folder name="Home">
        <var name="agentName" type="TEXT" initValue="Alice"
            description="The virtual agent's name." />
        <var name="userName" type="TEXT" initValue="SomeName" description="The user's name" />
    </var_folder>
</variables>

I don't want the user name input to be seperated from the sentence... Any suggestions?

Thanks!

3条回答
做个烂人
2楼-- · 2019-07-26 19:26
Melony?
3楼-- · 2019-07-26 19:33

The best way I’ve found is to use this entity instead:

<entity name="ANYTHING">
  <value>
    <grammar>
      <item>!.*</item>
    </grammar>
  </value>
</entity>

All examples from IBM contain the DYNAMIC_DATA thing, but it’s a really awful way of capturing data, since it silently loses many characters.

Examples of characters that are dropped are / \ " ! ? ( ) ° . , ; : _ – — > < = @. Try capturing an email address, for instance.

Then you use this to set a variable in exactly the same way.

<grammar>
  <item>my name is (ANYTHING)={userName}</item>
</grammar>

<action varName="userName" operator="SET_TO">{userName.source}</action>

What the above entity does is to use a regular expression to capture anything. The ! at the start means that everything following it is a regular expression.

查看更多
神经病院院长
4楼-- · 2019-07-26 19:44

You need to have an entity such as

<entity name="DYNAMIC_DATA" entityType="GENERIC">
    <value name="DataCapture" value="DataCapture">
        <grammar>
            <item>*</item>
        </grammar>
    </value>
    <entityRules/>
</entity>
查看更多
登录 后发表回答