首页 > 解决方案 > Bixby NL 使用整数数据类型

问题描述

如何从 Bixby 的 NL 培训中返回整数数据类型?输入视图使用滑块元素,概念设置为整数,所以我相信对话驱动程序/NL 需要输出整数而不是文本/字符串。在这种情况下,使用词汇文件显然行不通。

我认为它类似于 Money 角色输出浮点数的方式,即:

What can I get for {[g:viv.money.MaxPrice] ($)[v:viv.money.PrefixSymbol:$](40)[v:viv.money.CurrencyValue]}

标签: bixbybixbystudio

解决方案


当您的胶囊使用原始类型(在您的情况下为整数)时,最好创建您自己的从原始类型派生的类型。

integer (MyAge) {
  description (__DESCRIPTION__)
}

您的 NL 训练可能是这样的My age is 25,您可以将 25 标记为整数。

input-view {
  match: MyAge (this) {
    to-input: GetMyAge (action)
  }

  message {
    template (Testing MyAge)
  }

  render {

    form {
      // the intent that will be used when the form is submitted
      on-submit {
        goal: MyAge
        value: viv.core.FormElement(id)
      }

      elements {
        slider {
          step(1)
          id (id)
          type (viv.core.Integer)
          max-label ()
          min-value (1)
          max-value (123)
          value("#{value(action.integerValue)}")
        }
      }
    }
  }
}

action (GetMyAge) {
  type(Search)
  description (__DESCRIPTION__)

  collect {
    input (integerValue) {
      type (viv.core.Integer)
      min (Required) max (One)
      default-init {
        intent {
          goal: viv.core.Integer
          value: viv.core.Integer (1)
        }
      }
    }
    computed-input (myInteger) {
      type (viv.core.Integer)
      min (Required) max (One)
      compute {
        intent {
          goal: viv.core.Integer
        }
      }
    }
  }
  output (viv.core.Integer)

试试这个,让我们知道它是否有效。


推荐阅读