alexa-utterances icon indicating copy to clipboard operation
alexa-utterances copied to clipboard

Need to ability to have nested groups for utterances

Open rickwargo opened this issue 8 years ago • 6 comments

Nested groups are valuable when alternating pronouns or articles of speech in an utterance. For example:

(The best|(A|My) favorite) movie is {Movie}

should expand to:

The best movie is {Movie}
A favorite movie is {Movie}
My favorite movie is {Movie}

I'll work on creating a PR for this functionality.

rickwargo avatar May 18 '16 01:05 rickwargo

I'm not saying no to this, just playing devil's advocate:

couldn't this be supported by instead declaring the group as

(The best|A favorite|My favorite) movie is {Movie} ?

The nested syntax seems a bit terse.

mreinstein avatar May 18 '16 18:05 mreinstein

Definitely makes it harder to read at first. I find myself revisiting utterances and want to expand on the options. The example was quite simple and expanding it makes it easier to read. My templates often have a lot of alternation and I will expand on it to cover as many voice options as possible. When I do this I may want to use nested groups. Admittedly this does not happen often, and when I do need it, I just copy the template and expand upon it. When I do that, though, my utterance templates are not DRY. I'm fine either way considering the implementation is not simple ;)

rickwargo avatar May 18 '16 20:05 rickwargo

Here is an example that I have came across. Supposing that you are using the Amazon Slot types for both city and airport. As the user is going to ask either how long it with take to get to Los Angeles or LAX.

Currently I have to structure it like this:

    'slots': {
      "CITY": "AMAZON.CITY",
      "AIRPORT": "AMAZON.AIRPORT"
    },
    'utterances':[
      "for the {flight time | duration} to {-|CITY}",
      "for the {flight time | duration} to {-|AIRPORT}",

    ]

Would be nice not to have to repeat the initial part in the utterance. Something along these lines:

    'utterances':[
      "for the {flight time | duration} to {{-|CITY} | {-|AIRPORT}}"
    ]

Any insights appreciated!

scullum avatar Jan 27 '17 17:01 scullum

This is personal preference, but I find:

"for the {flight time | duration} to {-|CITY}",
"for the {flight time | duration} to {-|AIRPORT}",

to be more readable than:

 "for the {flight time | duration} to {{-|CITY} | {-|AIRPORT}}"

mreinstein avatar Jan 27 '17 18:01 mreinstein

I think you have a good thought, but I have to agree with mreinstein. I find utterances to be nearly the perfect balance of simple and powerful. There might be some cases where nested syntax might seem more convenient or even appropriate, but I haven't found anything you flat out can't do with the implementation as-is.

jlguinn avatar Feb 19 '17 00:02 jlguinn

+1 request for nesting support. The "flutterance" utility ( https://www.npmjs.com/package/flutterance ) supports nesting, but does not appear to work on it's own as a library to be included in a package. The specific example from their readme shows: [Hello|Hi|Good [Morning|Afternoon|Evening]] Alexa

... seems like a perfectly good use case. shrug

ericblade avatar Mar 22 '17 16:03 ericblade