@@ -143,18 +143,18 @@ function unset_all_bad_pattern_matches($allrows, $lookingfor, $current_thatpatte
143143 }
144144 else
145145 {
146- $ that_match = " $ aiml_thatpattern == '' " ;
146+ $ that_match = ( $ aiml_thatpattern == '' ) ;
147147 $ tmp_rows [$ i ]['track_score ' ] .= "c " ;
148148 }
149149 if ($ aiml_topic != '' )
150150 {
151- $ topic_match = " $ aiml_topic == $ current_topic" ;
151+ $ topic_match = ( $ aiml_topic == $ current_topic) ;
152152 $ tmp_rows [$ i ]['track_score ' ] .= "d " ;
153153 }
154154 else
155155 {
156- $ topic_match = " $ aiml_topic == '' " ;
157- $ tmp_rows [$ i ]['track_score ' ] .= "e " ;
156+ $ topic_match = ( $ aiml_topic == '' ) ;
157+ $ tmp_rows [$ i ]['track_score ' ] .= "xe " ;
158158 }
159159 //try to match the returned aiml pattern with the user input (lookingfor) and with the that's and topic's
160160 preg_match ($ aiml_pattern_matchme , $ lookingfor , $ matches );
@@ -177,25 +177,11 @@ function unset_all_bad_pattern_matches($allrows, $lookingfor, $current_thatpatte
177177 }
178178 else
179179 {
180+ if (!isset ($ tmp_rows [$ i ]['pattern ' ])) unset($ tmp_rows [$ i ]);
180181 continue ;
181- /*
182- $tmp_rows[$i] = array(
183- 'aiml_id' => -1,
184- 'bot_id' => -1,
185- 'pattern' => '',
186- 'thatpattern' => '',
187- 'topic' => '',
188- 'score' => 0,
189- 'track_score' => ''
190- );
191- */
192182 }
193- //echo "<br/>--------------";
194183 }
195184 }
196- // echo "<pre>";
197- // print_r($tmp_rows);
198- // echo "</pre>";
199185 runDebug (__FILE__ , __FUNCTION__ , __LINE__ , "Found ' $ i' relevant rows " , 2 );
200186 runDebug (__FILE__ , __FUNCTION__ , __LINE__ , print_r ($ tmp_rows ,true ), 4 );
201187 return $ tmp_rows ;
@@ -775,10 +761,7 @@ function find_aiml_matches($convoArr)
775761 else
776762 {
777763 $ thatPattern = '' ;
778- //$lastThatPattern = '';
779- //$firstThatPattern = '';
780764 $ thatPatternSQL = '' ;
781- //$storedthatpattern ='';
782765 }
783766 //get the word count
784767 $ word_count = wordsCount_inSentence ($ lookingfor );
@@ -833,6 +816,8 @@ function find_aiml_matches($convoArr)
833816 $ allrows [$ i ]['pattern ' ] = $ row ['pattern ' ];
834817 $ allrows [$ i ]['thatpattern ' ] = $ row ['thatpattern ' ];
835818 $ allrows [$ i ]['topic ' ] = $ row ['topic ' ];
819+ $ allrows [$ i ]['score ' ] = 0 ;
820+ $ allrows [$ i ]['track_score ' ] = '' ;
836821 $ i ++;
837822 $ mu = memory_get_usage (true );
838823 if ($ mu >= MEM_TRIGGER )
0 commit comments