botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

recognizeChoices function returns erroneous result when using utterance with index numbers

Open arieschwartzman opened this issue 4 years ago • 0 comments

Version

NodeJS SDK - package botbuilder-dialogs, version: 4.11.1

Describe the bug

recognizeChoices(utterance, choices, opt) function returns erroneous output when searching options using index numeric values in particular circumstances.

To Reproduce

pass the following parameters: utterance:

"1, 2, 3, 13"

choices:

["Fever or feeling feverish (such as chills sweating)", 
"Cough", 
"Mild or moderate difficulty breathing", 
"Sore throat", 
"Muscle aches or body aches", 
"Headache", 
"Vomiting or diarrhea", 
"New loss of taste or smell", 
"Congestion or runny nose", 
"New rash", 
"Unusual fatigue", 
"Joint pain", 
"Unusual chest pain or tightness in the chest", 
"Difficulty thinking or concentrating (sometimes referred to as “brain fog”)", 
"Depression anxiety changes in mood", 
"Fast-beating or pounding heart (also known as heart palpitations)", 
"Other symptoms", 
"No symptoms"]

opt:

{"allowPartialMatches": false, "locale": "en-us"}

Function returns the following:

[{"start":0,"end":0,"typeName":"choice","text":"1","resolution":{"value":"Fever or feeling feverish (such as chills sweating)","index":0,"score":1}},
{"start":3,"end":3,"typeName":"choice","text":"2","resolution":{"value":"Cough","index":1,"score":1}},
{"start":9,"end":10,"typeName":"choice","text":"13","resolution":{"value":"Unusual chest pain or tightness in the chest","index":12,"score":1}}]

*Notice that index "3" is missing. If we would eliminate the number "13" from the utterance, it will return 3. The same goes if I would enter utterance "1, 2, 4, 14". In this case, "4" will be missing from the output. If I would enter the "1,2,03,13" utterance, it will also work. Looks like the function will prefer the longer token if some of the numbers are included there and remove the shorter one. This is causing problems when there are more than 10 items in a list and selection is done via the prompt free text field.

Expected behavior

Function should return all entries that match the utterance number tokens

arieschwartzman avatar Apr 21 '21 09:04 arieschwartzman