匹配多个概念

Match multiple concept

希望显示我的输入视图,消息随时间变化,并显示基于另一个变量的内容。

这是我的输入视图

input-view{
    match{
        userWantToHear(this){
            from-output:getStart //action to get list of selection
        }
    }

    message{
        switch (this){//should be another value which is (timePeriod)
            case ("M"){
                template-macro (morning-template)
            }
            case ("A"){
                template-macro (afternoon-template)
            }
            case ("N"){
                template-macro (night-template)
            }
            default{
                template-macro (normal-template)
            }
        }
    }

    render{
        selection-of (this){ //this should be (userWantToHear)
            where-each (one){
                spoken-summary{ 
                    template ("#{value(one)}")
                }
                cell-card{
                    slot2{
                        content{
                            primary{
                                template ("#{value(one)}")
                            }
                        }
                    }
                }
            }
        }
    }
}

所以我的想法是,创建一个包含它们的结构。

structure (menu) {
  description (__DESCRIPTION__)
  property (timeperiod){
    type (timePeriod)
    min (Required) max (One)
  }

  property (whatuserwant) {
    type (userWantToHear)
    min (Required) max (One)
  }

}

而且我还创建了一个获取它们的操作。

action (getMenu) {
  type(Search)
    collect{
        input (timeperiod){
            type (timePeriod)
            min (Required) max (One)
            default-init{
                intent{
                    goal: getTime
                }
            }
        }
    input (whatuserwant){
      type (userWantToHear)
      min (Required) max (One)
      default-init{
        intent{
          goal: getStart
        }
      }
    }
    }
  output (menu)
}

输入视图的结果将传递到下面的操作中,即 userWantToHear

action (getNews) {
    type (Search)
    description (__DESCRIPTION__)
    collect {
        input (whatuserwant){
            type (userWantToHear)
            min (Required) max (One)
            default-init{
                intent{
                    goal: getMenu
                }
            }
        }
    }
    output (newsAudio)
}

所以我想知道输入视图将如何接受结构并为每个部分访问其中的 属性,并取回我想要的输入?目前在我这边,它能够获得选择,但消息不会根据 "timePeriod" 改变,我相信它还没有进入输入视图。

我认为您的 post 中有两个问题。

  1. 如何呈现不同的视图?答:使用 if-else 或 switch 语句到 select 模板宏。

  2. 如何访问不在 match Type(this) 中的概念?答:使用复杂的匹配模式 link 这些概念通过一个动作。考虑以下代码块。

  match: IntAge(this) {
    to-input: GetStructPerson (action)
  }
  message {
    template ("Enter age of #{value(action.name)}")
  }

您可以在 Bixby Developer Center

中阅读更多内容并下载示例胶囊