question

Rand M avatar image
Rand M asked

How to take large natural language numbers/amounts from a user?

Apologies if this has been addressed - I saw a few links, but not quite what I am looking for. I would like to take verbal amounts (e.g. dollars, flight altitudes, etc.) from the user without making the user enunciate each individual digit, for example if the user wants to specify $35, 721.98 how can he/she tell Alexa that without saying each digit? ("three" "five" "seven" "two" "one" "point" "nine" "eight" "dollars") = bad user experience. I'd like the user to be able to say it naturally, with possible variations of course, e.g. "thirty five thousand seven-hundred twenty-one point ninety-eight dollars" "thirty five thousand seven-hundred twenty-one point ninety-eight" "thirty five seven-hundred twenty-one and ninety-eight cents" etc. Since we are talking an upper range of 5-7 digits (along with 2 for the cents) and all the various ways to say that, the possibilities are enormous. Any ideas on how to approach this? Thanks in advance P.S. As a feature request, I would like to see this as a built-in part of the ASK - for example, the ability to specify a number (with possibly a min/max, number of decimal places etc.) in the Schema/utterances and have Amazon do the heavy lifting of converting whatever the user says to a decimal or String version of that without providing a slew of possible utterances.
alexa skills kitdebugging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Declare your slot to be of type numeric. That's what the ASK offers. Reports are it works pretty well. I haven't used it much. The only sort of numeric input I had was for the UPS package tracker. But those are alpha-numerics, so I couldn't use it. :-(
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jondecker76 avatar image
jondecker76 answered
Numeric slot types do work pretty well, even for large numbers. One caveat though is that they support integers only! To get around this just work with the limitation accordingly.. example: [code] intent schema entry: { "intent": "CreateWeightIntent", "slots": [ { "name": "weight", "type": "NUMBER" }, { "name": "decimal", "type": "NUMBER" } ] } utterances: CreateWeightIntent I weigh {one hundred sixy five|weight} pounds CreateWeightIntent I weigh {one hundred seventy five|weight} point {five|decimal} pounds CreateWeightIntent I weigh {one hundred fifty three|weight} CreateWeightIntent I weigh {nenety three|weight} point {one|decimal} CreateWeightIntent my weight is {two hundred sixty nine|weight} pounds CreateWeightIntent my weight is {three hundred sixty two|weight} point {six|decimal} pounds CreateWeightIntent my weight is {two hundred sixty nine|weight} CreateWeightIntent my weight is {three hundred sixty two|weight} point {six|decimal} CreateWeightIntent I am {one hundred|weight} pounds CreateWeightIntent I am {one hundred three|weight} point {seven|decimal} pounds code: if(decimalSlot && decimalSlot.value) { decimal=decimalSlot.value; decimal=Number(decimal); decimal=decimal/10; } if(weightSlot && weightSlot.value) { weight=weightSlot.value; weight=Number(weight); if(decimal) { weight+=Number(decimal); } } [/code] it's actually not too bad to work with in my experience so far. It's a bit of a pain to have to give utterances for cases both with and without a decimal value, but still plenty workable
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rand M avatar image
Rand M answered
Thanks a lot, guys, that should do the trick. I copy/pasted Jon's utterances and it seems to recognize "thousand" also - bizarre. Fwiw, the same issue applies to phone numbers and all the different ways to say them, combine digits, etc, sigh... I appreciate your help.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

N. Fradkin avatar image
N. Fradkin answered
In my experience numbers do not work well unless you create sample utterances for a decent number of samples that includes at least one of each variation in number of words involved in saying the number. Have the set of samples also contain as many different words for numbers as possible. At one point I had a utterance that took a percentage and I had only a few examples like one ,twenty five ,fifty. It would recognize some unrepresented numbers but not others. Twenty one worked, but twenty three was right out. On the other hand, I have an utterance that expects a you to say a number from 1000-9999, and so far with just there four examples I haven't run across a number it fails on (though I've probably only done a few dozen examples so who knows). one thousand nine hundred twenty four two thousand eight hundred thirty five three thousand thirty seven four thousand two hundred ninety five
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.