如何在结果视图中匹配枚举符号?

时间:2019-07-25 16:28:16

标签: bixby

我有一些目标相同的训练示例,但是使用枚举/符号(以减少所需的训练示例)。

如何在结果视图中匹配符号?

我在以下文档中查看了模式匹配:https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.match-patterns

我认为这很简单。我有一个枚举:

enum (sizes) {
  description (drink sizes)
  symbol (large)
  symbol (medium)
  symbol (small) 
}

以及一些相应的词汇:

vocab (sizes) {
"large" {"large", "largest", "big"}
"medium" {"medium", "normal"}
"small" {"small", "smallest", "tiny"}
}

然后为了训练,我可能会:

[g:BuyDrink] I want a (large)[v:sizes:large] drink
[g:BuyDrink] I want the (smallest)[v:sizes:small] drink

我希望两种发音的结果视图不同,但我无法弄清楚正确的匹配模式。

1 个答案:

答案 0 :(得分:2)

匹配模式适用于概念类型。渲染视图时,您应该能够为值的任何变化创建布局。例如:

操作:

action (BuyDrink) {
  type(Search)
  description (Buy a drink (small, medium, or large))
  collect {
    input (size) {
      type (sizes)
      min (Optional) max (One)
    }
  }
  output (sizes)
}

查看:

  result-view {
      match {
        sizes(drinkSize) {
          from-output: BuyDrink(drink) 
        }

      }

      render {

        if (drinkSize  == 'large') {
          layout-macro (large)
        }
        else-if (drink == 'medium') {
          layout-macro (medium)
        }
        else {
          layout-macro (small)
        }

      }

    }

大布局:

layout-macro-def (large) {
  content {
    single-line {
      text(This is LARGE)
    }
  }
}

中等布局:

layout-macro-def (medium) {
  content {
    single-line {
      text(This is Medium)
    }
  }
}

小布局:

layout-macro-def (small) {
  content {
    single-line {
      text(This is small)
    }
  }
}