Skip to content

Commit 28a1127

Browse files
committed
Bug Fixes, and updated the install SQL
1 parent 86f5d57 commit 28a1127

File tree

8 files changed

+237
-115
lines changed

8 files changed

+237
-115
lines changed

chatbot/conversation_start.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,6 @@
175175
runDebug(__FILE__, __FUNCTION__, __LINE__, "Closing Database", 2);
176176
db_close($con);
177177
#echo $display;
178+
//save_file(_DEBUG_PATH_ . 'function_list.txt', print_r(get_defined_functions(), true));
178179
$convoArr = handleDebug($convoArr); // Make sure this is the last line in the file, so that all debug entries are captured.
179180
if (isset($convoArr['conversation']['format'])) display_conversation($display, $convoArr['conversation']['format']);

chatbot/core/aiml/find_aiml.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ function unset_all_bad_pattern_matches($allrows, $lookingfor, $current_thatpatte
179179
}
180180
}
181181
}
182+
else
183+
{
184+
$tmp_rows[$i] = array(
185+
'aiml_id' => -1,
186+
'bot_id' => -1,
187+
'pattern' => '',
188+
'thatpattern' => '',
189+
'topic' => '',
190+
'score' => 0,
191+
'track_score' => ''
192+
);
193+
/*
194+
*/
195+
}
182196
//echo "<br/>--------------";
183197
}
184198
}
@@ -397,6 +411,7 @@ function score_matches($convoArr, $bot_parent_id, $allrows, $lookingfor, $curren
397411
print_r($allrows);
398412
echo "</pre>";
399413
*/
414+
runDebug(__FILE__, __FUNCTION__, __LINE__,"Returned array:\n" . print_r($allrows, true), 4);
400415
return $allrows;
401416
//return the scored rows
402417
}
@@ -415,8 +430,8 @@ function sort2DArray($opName, $thisArr, $sortByItem, $sortAsc = 1, $limit = 10)
415430
{
416431
$thisCount = count($thisArr);
417432
$showLimit = ($thisCount < $limit) ? $thisCount : $limit;
418-
runDebug(__FILE__, __FUNCTION__, __LINE__, "$opName - sorting $thisCount results by $sortByItem and getting the top $showLimit for debugging.", 4);
419433
runDebug(__FILE__, __FUNCTION__, __LINE__, print_r($thisArr, true), 4);
434+
runDebug(__FILE__, __FUNCTION__, __LINE__, "$opName - sorting $thisCount results by $sortByItem and getting the top $showLimit for debugging.", 4);
420435
$i = 0;
421436
$tmpSortArr = array();
422437
$resArr = array();

chatbot/core/aiml/parse_aiml_as_XML.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ function parse_input_tag($convoArr, $element, $parentName, $level)
617617
{
618618
runDebug(__FILE__, __FUNCTION__, __LINE__, 'Parsing an INPUT tag.', 2);
619619
$element = $element->input;
620-
$index = $element['index'];
621-
$index = (!empty ($index)) ? $index : 1;
622-
runDebug(__FILE__, __FUNCTION__, __LINE__, "Parsing the INPUT tag. Index = $index.", 4);
623-
$response_string = $convoArr['input'][$index];
620+
$input_index = (string)$element['index'];
621+
$input_index = (!empty ($input_index)) ? $input_index : 1;
622+
runDebug(__FILE__, __FUNCTION__, __LINE__, "Parsing the INPUT tag. Index = $input_index.", 4);
623+
$response_string = $convoArr['input'][$input_index];
624624
return $response_string;
625625
}
626626

chatbot/core/conversation/intialise_conversation.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,21 +609,25 @@ function load_that($convoArr)
609609
$user_id = $convoArr['conversation']['user_id'];
610610
$bot_id = $convoArr['conversation']['bot_id'];
611611
$limit = $remember_up_to;
612-
$sql = "select `response` from `$dbn`.`conversation_log` where `user_id` = $user_id and `bot_id` = $bot_id order by `id` asc limit $limit;"; // desc
612+
$sql = "select `input`, `response` from `$dbn`.`conversation_log` where `user_id` = $user_id and `bot_id` = $bot_id order by `id` asc limit $limit;"; // desc
613613
runDebug(__FILE__, __FUNCTION__, __LINE__, "Getting conversation log entries for the current user. SQL:\n$sql", 3);
614614
$result = db_query($sql, $con);
615615
if ($result)
616616
{
617-
$tmpRows = array();
617+
$tmpThatRows = array();
618+
$tmpInputRows = array();
618619
$tmpThat = array();
620+
$tmpInput = array();
619621
$puncuation = array(',', '?', ';', '!');
620622
while ($row = mysql_fetch_assoc($result))
621623
{
622-
$tmpRows[] = $row['response'];
624+
$tmpThatRows[] = $row['response'];
625+
$tmpInputRows[] = $row['input'];
623626
}
624-
runDebug(__FILE__, __FUNCTION__, __LINE__, 'Finished loading previous responses into the ~THAT~ array.', 4);
625-
array_reverse($tmpRows);
626-
foreach ($tmpRows as $row)
627+
runDebug(__FILE__, __FUNCTION__, __LINE__, 'Inputs returned:' . print_r($tmpInputRows, true), 1);
628+
runDebug(__FILE__, __FUNCTION__, __LINE__, 'Loading previous responses into the ~THAT~ array.', 4);
629+
array_reverse($tmpThatRows);
630+
foreach ($tmpThatRows as $row)
627631
{
628632
$row = str_replace($puncuation, '.', $row);
629633
$tmpThat[] = explode('.', $row);
@@ -636,9 +640,24 @@ function load_that($convoArr)
636640
$value = clean_that($value, __FILE__, __FUNCTION__, __LINE__);
637641
$convoArr = push_on_front_convoArr('that', $value, $convoArr);
638642
}
643+
runDebug(__FILE__, __FUNCTION__, __LINE__, 'Loading previous user inputs into the ~INPUT~ array.', 4);
644+
array_reverse($tmpInputRows);
645+
foreach ($tmpInputRows as $row)
646+
{
647+
$row = str_replace($puncuation, '.', $row);
648+
$tmpInput[] = explode('.', $row);
649+
}
650+
array_unshift($tmpThat, NULL);
651+
unset ($tmpThat[0]);
652+
foreach ($tmpInput as $index => $value)
653+
{
654+
$value = implode_recursive(' ', $value, __FILE__, __FUNCTION__, __LINE__);
655+
$value = clean_that($value, __FILE__, __FUNCTION__, __LINE__);
656+
$convoArr = push_on_front_convoArr('input', $value, $convoArr);
657+
}
639658
}
659+
else runDebug(__FILE__, __FUNCTION__, __LINE__, 'Couldn\'t find any previous inputs or responses.', 4);
640660
mysql_free_result($result);
641661
return $convoArr;
642662
}
643-
644-
?>
663+
?>

gui/xml/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function get_convo_id()
109109
}
110110
</style>
111111
</head>
112-
<body>
112+
<body onload="document.forms[0].say.focus();">
113113
<h3>Program O XML GUI</h3>
114114
<form accept-charset="utf-8" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
115115
<p>

0 commit comments

Comments
 (0)