@@ -34,6 +34,16 @@ var SimplePromptRecognizer = (function () {
34
34
function SimplePromptRecognizer ( ) {
35
35
}
36
36
SimplePromptRecognizer . prototype . recognize = function ( args , callback , session ) {
37
+ function findChoice ( args , text ) {
38
+ var best = entities . EntityRecognizer . findBestMatch ( args . enumValues , text ) ;
39
+ if ( ! best ) {
40
+ var n = entities . EntityRecognizer . parseNumber ( text ) ;
41
+ if ( ! isNaN ( n ) && n > 0 && n <= args . enumValues . length ) {
42
+ best = { index : n - 1 , entity : args . enumValues [ n - 1 ] , score : 1.0 } ;
43
+ }
44
+ }
45
+ return best ;
46
+ }
37
47
var score = 0.0 ;
38
48
var response ;
39
49
var text = args . utterance . trim ( ) ;
@@ -53,9 +63,9 @@ var SimplePromptRecognizer = (function () {
53
63
case PromptType . confirm :
54
64
var b = entities . EntityRecognizer . parseBoolean ( text ) ;
55
65
if ( typeof b !== 'boolean' ) {
56
- var n = entities . EntityRecognizer . parseNumber ( text ) ;
57
- if ( ! isNaN ( n ) && n > 0 && n <= 2 ) {
58
- b = ( n === 1 ) ;
66
+ var best = findChoice ( args , text ) ;
67
+ if ( best ) {
68
+ b = ( best . index === 0 ) ;
59
69
}
60
70
}
61
71
if ( typeof b == 'boolean' ) {
@@ -71,13 +81,7 @@ var SimplePromptRecognizer = (function () {
71
81
}
72
82
break ;
73
83
case PromptType . choice :
74
- var best = entities . EntityRecognizer . findBestMatch ( args . enumValues , text ) ;
75
- if ( ! best ) {
76
- var n = entities . EntityRecognizer . parseNumber ( text ) ;
77
- if ( ! isNaN ( n ) && n > 0 && n <= args . enumValues . length ) {
78
- best = { index : n - 1 , entity : args . enumValues [ n - 1 ] , score : 1.0 } ;
79
- }
80
- }
84
+ var best = findChoice ( args , text ) ;
81
85
if ( best ) {
82
86
score = best . score ;
83
87
response = best ;
@@ -173,7 +177,7 @@ var Prompts = (function (_super) {
173
177
if ( Channel . supportsKeyboards ( session , args . enumValues . length ) ) {
174
178
style = ListStyle . button ;
175
179
}
176
- else if ( ! retry ) {
180
+ else if ( ! retry && args . promptType == PromptType . choice ) {
177
181
style = args . enumValues . length < 3 ? ListStyle . inline : ListStyle . list ;
178
182
}
179
183
else {
0 commit comments