MycroftAI / adapt

Adapt Intent Parser
Apache License 2.0
709 stars 155 forks source link

Number support #16

Closed baudren closed 8 years ago

baudren commented 8 years ago

For an intent parser I created, where you could ask the timetable for a specific bus line, I had to write down the possible numbers for bus lines. But then, typing real numbers from the command line, e.g. when is the next bus sixty-one leaving from home? starts to be annoying.

Would it be possible to build in a support for numbers, somehow? I know of the library inflect that translates integers to text, which would help quite a bit on this. There is also pynum2word.

I think that being able to specify a new sort of entity (i.e. a numerical entity) would be nice. Something where you specify a range, say 1 to 100, and it will then understand both 1 and sixty-one, preferably returning the integer version in the json structure.

baudren commented 8 years ago

Kind of a duplicate to #7, sorry. Still, having number support would be nice. Maybe we can discuss here what it would take to make a better support for at least numbers written like 20, in the engine? Using regex for specifying a range can be quite painful...

The advantage of something like pynum2word is the sort of multilanguage support, also. Speaking of which: what is the plan for putting in localisation support? Will this be part of another package, somehow?

clusterfudge commented 8 years ago

Still a duplicate of #7 , and I haven't had time to think through how I want to do this in a language agnostic way. I'd prefer to use something that's a reversal of pynum2word (or the like).

Short term, I imagine that your bus line data source has a static set of routes? If so, you could consume that and use pynum2word or inflect to populate the vocabulary automatically, as opposed to maintaining a list of number-to-word mappings.

https://github.com/MycroftAI/adapt/commit/1da3760963c8f6bf603e4d24a121269ca1d5dccb

The above commit introduced alias support, which should allow you to map the numeral-words back to the integer values, albeit as strings.

baudren commented 8 years ago

Nice, I did not know about the alias feature. Sounds like a good solution in the meantime, thanks. Feel free to close the issue if it is not on your radar for the foreseeable future.