首页 > 解决方案 > how to make Bixby treat user vocabulary terms as equivalent

问题描述

I have the concept of a "Pack" in my product which is a collection or bundle of content that a user can purchase. I would like to make Bixby treat the terms "pack", "collection", and "bundle" as equivalent while within my capsule, so that saying "show me available bundles" is equivalent to "show me available packs".

I tried creating a file called resources/target/pack.vocab.bxb with these contents:

vocab (altbrains.quotations.Pack) {
  "pack" {"Pack", "bundle", "collection"}
}

my Pack concept file is Pack.model.bxb:

structure (Pack) 
  { property (title) {
    type (Title)
    min (Required)
  }
  property (price) {
    type (Price)
    min (Required)
  }
  property (brand) {
    type (Brand)
    min (Required)
  }
  property (description) {
    type (Description)
    min (Required)
  }
  property (images) {
    type (Image)
    min (Required) max (Many)
  }
  property (language){
    type (Language)
    min (Optional) max (Many)
}
}

My Content.model.bxb is:

structure (Content) {
  description (Output)
  property (text) {
    type (core.Text)
    min (Optional) max (One)
    visibility (Private)
  }
  property (image) {
    type (image.Image)
    min (Optional) max (One)
    visibility (Private)
  }
}

The vocab file above produces a bunch of error messages (10) in the compiler saying "invalid vocab term, structured value may not have a symbol"

I want the vocab file to compile and I want a test story using "list my available bundles" to work the same as a test story saying "list my available packages"

标签: bixbybixbystudio

解决方案


试试这样......

表达:给我看看我的包

为:“packEnum”创建枚举。

创建一个词汇:packEnum, "pack","bundle","collection"

创建 Pack 的结构:你已经有了

创建一个 showPacks.js:它应该返回一个 Pack 对象。

创建一个动作:ShowPack。ShowPack 接受 packEnum 的输入并返回 Pack 结构。

将 ShowPack 操作映射到端点中的 showPack.js

为 PackView 和 PackDialog 创建与 Pack 匹配的视图和对话框。

创建 [g:ShowPack] show (pack)[v:packEnum] 的话语。

然后,当您说“显示集合”时,它将映射到 ShowPack 操作,该操作执行 showPacks.js 并加载所有包,这些包由 PackView/Dialog 显示。

在您的情况下,您似乎正在尝试将 Pack 结构视为输入,但它实际上是对要显示的操作的响应。你需要一些可以作为行动输入的东西。


推荐阅读