Skip to content

Commit 3c7945c

Browse files
committed
Adding missing conditional to score wildcard patterns with thatpatterns
1 parent 5df12bd commit 3c7945c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

chatbot/core/aiml/find_aiml.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,37 @@ function score_matches($convoArr, $bot_parent_id, $allrows, $lookingfor, $curren
322322
$allrows[$all]['score'] += $that_pattern_match_general;
323323
$allrows[$all]['track_score'] .= "g";
324324
}
325+
} elseif ($aiml_pattern == "*") {
326+
327+
if (($aiml_thatpattern == $current_thatpattern) && ($aiml_thatpattern != '')) {
328+
$allrows[$all]['score'] += $that_pattern_match;
329+
$allrows[$all]['track_score'][] = "h";
330+
331+
} elseif (($aiml_thatpattern_wildcards != '') && ($aiml_thatpattern != '') && (preg_match($aiml_thatpattern_wildcards, $current_thatpattern, $m))) {
332+
$allrows[$all]['score'] += $that_pattern_match;
333+
$allrows[$all]['track_score'][] = "i";
334+
}
335+
325336
}
326337
//if stored result == default pattern increase score
327338
$aiml_pattern = (IS_MB_ENABLED) ? mb_strtolower($aiml_pattern) : strtolower($aiml_pattern);
328339
$default_pattern = (IS_MB_ENABLED) ? mb_strtolower($default_pattern) : strtolower($default_pattern);
329340
if ($aiml_pattern == $default_pattern)
330341
{
331342
$allrows[$all]['score'] += $pattern_points;
332-
$allrows[$all]['track_score'] .= "h";
343+
$allrows[$all]['track_score'] .= "j";
333344
}
334345
elseif ($aiml_pattern == "*")
335346
{
336347
//if stored result == * increase score
337348
$allrows[$all]['score'] += $starscore_points;
338-
$allrows[$all]['track_score'] .= "i";
349+
$allrows[$all]['track_score'] .= "k";
339350
}
340351
elseif ($aiml_pattern == "_")
341352
{
342353
//if stored result == _ increase score
343354
$allrows[$all]['score'] += $underscore_points;
344-
$allrows[$all]['track_score'] .= "j";
355+
$allrows[$all]['track_score'] .= "l";
345356
}
346357
else
347358
{
@@ -358,31 +369,31 @@ function score_matches($convoArr, $bot_parent_id, $allrows, $lookingfor, $curren
358369
{
359370
// if it is a direct word match increase with (lower) score
360371
$allrows[$all]['score'] += $direct_word_match_points;
361-
$allrows[$all]['track_score'] .= "x";
372+
$allrows[$all]['track_score'] .= "m";
362373
}
363374
if (in_Array($word, $common_words_array))
364375
{
365376
// if it is a commonword increase with (lower) score
366377
$allrows[$all]['score'] += $common_word_points;
367-
$allrows[$all]['track_score'] .= "k";
378+
$allrows[$all]['track_score'] .= "n";
368379
}
369380
elseif ($word == "*")
370381
{
371382
$allrows[$all]['score'] += $starscore_points;
372383
//if it is a star wildcard increase score
373-
$allrows[$all]['track_score'] .= "l";
384+
$allrows[$all]['track_score'] .= "o";
374385
}
375386
elseif ($word == "_")
376387
{
377388
$allrows[$all]['score'] += $underscore_points;
378389
//if it is a underscore wildcard increase score
379-
$allrows[$all]['track_score'] .= "m";
390+
$allrows[$all]['track_score'] .= "p";
380391
}
381392
else
382393
{
383394
$allrows[$all]['score'] += $uncommon_word_points;
384395
//else it must be an uncommon word so increase the score
385-
$allrows[$all]['track_score'] .= "n";
396+
$allrows[$all]['track_score'] .= "q";
386397
}
387398
}
388399
}

0 commit comments

Comments
 (0)