Skip to content

Commit 52c9184

Browse files
committed
Bug fixes
1.) Corrected a bug where certain AIML categories that contain Unicode characters were being rejected 2.) (not really a bug) Streamlined the SQL query to eliminate extra elements that aren't necessary in most situations
1 parent 109929a commit 52c9184

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

chatbot/core/aiml/find_aiml.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ function unset_all_bad_pattern_matches($allrows, $lookingfor, $current_thatpatte
120120
//get the topic
121121
$aiml_thatpattern = $subrow['thatpattern'];
122122
//get the that
123-
$aiml_pattern = (IS_MB_ENABLED) ? mb_strtolower($aiml_pattern) : strtolower($aiml_pattern);
124-
$default_pattern = (IS_MB_ENABLED) ? mb_strtolower($default_pattern) : strtolower($default_pattern);
123+
//$aiml_pattern = (IS_MB_ENABLED) ? mb_strtolower($aiml_pattern) : strtolower($aiml_pattern);
124+
//$default_pattern = (IS_MB_ENABLED) ? mb_strtolower($default_pattern) : strtolower($default_pattern);
125125
if ($aiml_pattern == $default_pattern)
126126
{
127127
//if it is a direct match with our default pattern then add to tmp_rows
@@ -186,6 +186,7 @@ function unset_all_bad_pattern_matches($allrows, $lookingfor, $current_thatpatte
186186
// print_r($tmp_rows);
187187
// echo "</pre>";
188188
runDebug(__FILE__, __FUNCTION__, __LINE__, "Found '$i' relevant rows", 2);
189+
runDebug(__FILE__, __FUNCTION__, __LINE__, print_r($tmp_rows,true), 4);
189190
return $tmp_rows;
190191
}
191192

@@ -772,14 +773,19 @@ function find_aiml_matches($convoArr)
772773
}
773774
//get the word count
774775
$word_count = wordsCount_inSentence($lookingfor);
775-
if ($bot_parent_id != 0)
776+
if ($bot_parent_id != 0 and $bot_parent_id != $bot_id)
776777
{
777778
$sql_bot_select = " (bot_id = '$bot_id' OR bot_id = '$bot_parent_id') ";
778779
}
779780
else
780781
{
781782
$sql_bot_select = " bot_id = '$bot_id' ";
782783
}
784+
if ($storedtopic != '')
785+
{
786+
$topic_select = "(`topic`='') OR (`topic`='$storedtopic')";
787+
}
788+
else $topic_select = "`topic`=''";
783789
if ($word_count == 1)
784790
{
785791
//if there is one word do this
@@ -801,7 +807,7 @@ function find_aiml_matches($convoArr)
801807
($sql_add) OR
802808
(`pattern` = '$aiml_pattern' ))
803809
AND ((`thatpattern` = '_') OR (`thatpattern` = '*') OR (`thatpattern` = '') OR (`thatpattern` like '%') OR (`thatpattern` = '$lastthat') $thatPatternSQL )
804-
AND ((`topic`='') OR (`topic`='$storedtopic')));";
810+
AND ($topic_select));";
805811
}
806812
runDebug(__FILE__, __FUNCTION__, __LINE__, "Match AIML sql: $sql", 3);
807813
$result = db_query($sql, $con);

0 commit comments

Comments
 (0)