1

I have some training examples that have the same goal, but use enums/symbols (to reduce the training examples needed.)

How can I match the symbols in a result view?

I've looked at pattern matching in the docs here: https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.match-patterns

I think this is pretty straightforward. I have an enum:

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

And some corresponding vocabulary:

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

And then for training I might have:

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

I want different result views for the two utterances, but I can't figure out the correct match pattern.

sarkon
  • 187
  • 2
  • 8
  • Please be aware that enums typically do not reduce the number of training examples needed as indicated in your question. Enums simply limit the input to a valid enum value (extended with vocab). Without an enum, Bixby training will accept any phrase as input. Also note when creating training it's good to double check different phrase lengths - if you train on "Find a foo bar foo" with "foo bar foo" being the concept, Bixby NLU should pick up any phrase three words or shorter - additional training may be needed for longer phrases – rogerkibbe Jul 30 '19 at 01:13

1 Answers1

2

The match pattern will work for concept types. You should be able to create a layout for any variations of the value when you render the view. For example:

Action:

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

View:

  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)
        }

      }

    }

Large layout:

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

Medium layout:

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

Small layout:

layout-macro-def (small) {
  content {
    single-line {
      text(This is small)
    }
  }
}
Pete Haas
  • 1,800
  • 1
  • 12
  • 15