@@ -175,6 +175,10 @@ var findCorrectCategory = function(clientInput, domCategories){
175
175
text = resolveSpecialNodes ( childNodesOfTemplate ) ;
176
176
return text ;
177
177
}
178
+ else if ( childNodesOfTemplate [ i ] . name === 'star' ) {
179
+ text = resolveSpecialNodes ( childNodesOfTemplate ) ;
180
+ return text ;
181
+ }
178
182
else {
179
183
//this is the text of template node
180
184
//after all special functions (bot, get, set,...) were resolved
@@ -218,6 +222,7 @@ var findCorrectCategory = function(clientInput, domCategories){
218
222
else if ( innerNodes [ i ] . name === 'sr' ) {
219
223
var result ;
220
224
225
+ //for-loop to go through all loaded AIML files
221
226
for ( var j = 0 ; j < domArray . length ; j ++ ) {
222
227
result = findCorrectCategory ( lastWildCardValue , domArray [ j ] . children ) ;
223
228
//if in one of the dom trees a matching pattern was found, exit this inner loop
@@ -227,6 +232,9 @@ var findCorrectCategory = function(clientInput, domCategories){
227
232
}
228
233
}
229
234
}
235
+ else if ( innerNodes [ i ] . name === 'star' ) {
236
+ text = text + lastWildCardValue ;
237
+ }
230
238
else {
231
239
//normal text (no special tag)
232
240
text = text + innerNodes [ i ] . text ;
@@ -305,26 +313,27 @@ var getWildCardValue = function(userInput, patternText){
305
313
var replaceArray = patternText . split ( '*' ) ;
306
314
var wildCardInput = userInput ;
307
315
308
- //replace the string of the userInput which is fixed by the pattern
309
- for ( var i = 0 ; i < replaceArray . length ; i ++ ) {
310
- wildCardInput = wildCardInput . replace ( replaceArray [ i ] , '|' ) ;
311
- }
312
- //split the wildCardInput string by | to differentiate multiple * inputs
313
- //e.g. userInput = WHAT IS THE RELATION BETWEEN TIM AND STRUPPI?
314
- //-> | TIM | STRUPPI
315
- //-> [TIM, STRUPPI]
316
- wildCardInput = wildCardInput . split ( '|' ) ;
317
- //split function can create an array which also includes spaces etc. -> e.g. [TIM, " ", "", STRUPPI, " "]
318
- //we just want the information
319
-
320
- var wildCardArrayIndex = 0 ;
321
- for ( var i = 0 ; i < wildCardInput . length ; i ++ ) {
322
- if ( wildCardInput [ i ] != '' && wildCardInput [ i ] != ' ' && wildCardInput != undefined ) {
323
- wildCardArray [ wildCardArrayIndex ] = wildCardInput [ i ] ;
324
- wildCardArrayIndex ++ ;
325
-
326
- if ( ! wildCardInput [ i + 1 ] ) {
327
- lastWildCardValue = wildCardArray [ wildCardArrayIndex - 1 ] ;
316
+ if ( replaceArray . length > 1 ) {
317
+ //replace the string of the userInput which is fixed by the pattern
318
+ for ( var i = 0 ; i < replaceArray . length ; i ++ ) {
319
+ wildCardInput = wildCardInput . replace ( replaceArray [ i ] , '|' ) ;
320
+ }
321
+ //split the wildCardInput string by | to differentiate multiple * inputs
322
+ //e.g. userInput = WHAT IS THE RELATION BETWEEN TIM AND STRUPPI?
323
+ //-> | TIM | STRUPPI
324
+ //-> [TIM, STRUPPI]
325
+ wildCardInput = wildCardInput . split ( '|' ) ;
326
+ //split function can create an array which also includes spaces etc. -> e.g. [TIM, " ", "", STRUPPI, " "]
327
+ //we just want the information
328
+ var wildCardArrayIndex = 0 ;
329
+ for ( var i = 0 ; i < wildCardInput . length ; i ++ ) {
330
+ if ( wildCardInput [ i ] != '' && wildCardInput [ i ] != ' ' && wildCardInput != undefined ) {
331
+ wildCardArray [ wildCardArrayIndex ] = wildCardInput [ i ] ;
332
+ wildCardArrayIndex ++ ;
333
+
334
+ if ( ! wildCardInput [ i + 1 ] ) {
335
+ lastWildCardValue = wildCardArray [ wildCardArrayIndex - 1 ] ;
336
+ }
328
337
}
329
338
}
330
339
}
0 commit comments