コード例 #1
0
/**
* Main container function in creating the bot's reply.
*
* This function is the 'manager' of all the sub-funtions that do the real processing. It creates a class
* called Response that is used throughout the application.
*
* @uses addinputs()
* @uses addthats()
* @uses bget()
* @uses cleanup()
* @uses getthat()
* @uses loadcustomtags()
* @uses logconversation()
* @uses normalsentences()
* @uses respond()
* @uses ss_timing_current()
* @uses ss_timing_start()
* @uses ss_timing_stop()
*
* @global string that                   The conversation's previous bot output
* @global string topic                  The contents of the AIML tag 'Topic'
* @global integer uid                   The session ID of the user (previously $uniqueid)
* @global integer loopcounter           Counts the number of time a particular category is used in the same match trace.
* @global array patternmatched          The pattern's that matched the
*
* @param string $userinput              The user's input.
* @param integer $uniqueid              The user's session ID.
* @param integer $bot                   The bot's ID.
*
* @return object                        A class link to 'Response'.
*/
function reply($userinput, $uniqueid, $bot)
{
    if (strstr($userinput, "There is no such a bot loaded")) {
        $myresponse->response = $userinput;
    } else {
        global $that, $topic, $uid, $loopcounter, $patternmatched, $inputmatched, $selectbot;
        cleanup();
        ss_timing_start("all");
        $patternmatched = array();
        $inputmatched = array();
        $myresponse = new Response();
        $myresponse->errors = "";
        $uid = $uniqueid;
        $selectbot = $bot;
        // Load the custom plugin tags
        loadcustomtags();
        // Get the "that" and the "topic"
        $that = getthat(1, 1);
        $topic = bget("TOPIC");
        // Normalize the input
        $allinputs = normalsentences($userinput);
        // If nothing said then use INACTIVITY special input
        if (sizeof($allinputs) == 0) {
            $allinputs[] = "INACTIVITY";
        }
        // Put all the inputs into the <input> stack.
        addinputs($allinputs);
        $finalanswer = "";
        // Build our response to all of the inputs.
        for ($x = 0; $x < sizeof($allinputs); $x++) {
            $finalanswer .= respond($allinputs[$x]);
        }
        if ($loopcounter > LOOPINGLIMIT && LOOPINGLIMIT != -1) {
            $finalanswer = LOOPINGERRORMSG;
            $myresponse->errors = "LOOPINGLIMIT";
        }
        // Put the final answers into the <that> stack.
        addthats(normalsentences($finalanswer));
        // Log the conversation
        logconversation($userinput, $finalanswer);
        $myresponse->response = $finalanswer;
        $myresponse->patternsmatched = $patternmatched;
        $myresponse->inputs = $inputmatched;
        ss_timing_stop("all");
        $myresponse->timer = ss_timing_current("all");
    }
    return $myresponse;
}
コード例 #2
0
ファイル: phpenv.php プロジェクト: quartemer/xoopserver
function ss_timing_start($name = 'default')
{
    global $ss_timing_start_times;
    $ss_timing_start_times[$name] = explode(' ', microtime());
}
function ss_timing_stop($name = 'default')
{
    global $ss_timing_stop_times;
    $ss_timing_stop_times[$name] = explode(' ', microtime());
}
function ss_timing_current($name = 'default')
{
    global $ss_timing_start_times, $ss_timing_stop_times;
    if (!isset($ss_timing_start_times[$name])) {
        return 0;
    }
    if (!isset($ss_timing_stop_times[$name])) {
        $stop_time = explode(' ', microtime());
    } else {
        $stop_time = $ss_timing_stop_times[$name];
    }
    // do the big numbers first so the small ones aren't lost
    $current = $stop_time[1] - $ss_timing_start_times[$name][1];
    $current += $stop_time[0] - $ss_timing_start_times[$name][0];
    return $current;
}
ss_timing_start();
phpinfo();
ss_timing_stop();
echo "<hr><br>\r\n      <div class=\"confirm\">The page was executed in : " . ss_timing_current() . " seconds.</div>";
include_once "http://localhost/a/plugins/themefooter.html";
コード例 #3
0
ファイル: botloaderinc.php プロジェクト: aparaschivoiu/webapp
$startupwhich = "";
$splitterarray = array();
$inputarray = array();
$genderarray = array();
$personarray = array();
$person2array = array();
if (!isset($HTTP_GET_VARS['fileid'])) {
    #deletebot();
    $fileid = 1;
} else {
    $fileid = $HTTP_GET_VARS['fileid'];
}
#deletejustbot();
$doneloading = loadstartupinc($fileid);
$fileid++;
makesubscode();
print "<font size='3' color='BLUE'>Inserted {$templatesinserted} categories into database</font><br><BR>\n";
if ($doneloading == 0) {
    print "<p><font size='3' color='BLACK'><a href='botloaderinc.php?fileid={$fileid}'>Click here to load the next file.</a></p></font>\n";
} else {
    print "<font size='3' color='RED'><b>DONE LOADING</B><BR></font>\n";
    print "<font size='3' color='RED'><b>WARNING!</b> You should password protect the admin directory or remove the botloader.php script or people may be able to abuse your server.</b></font>\n";
    print "<p><font size='3' color='BLACK'><a href='../talk.php'>Click here to talk to the bot</a></p></font>\n";
}
print "<BR>";
ss_timing_stop("all");
print "<BR><BR><font size='3' color='BLACK'>execution time: " . ss_timing_current("all");
$avgts = $templatesinserted / ss_timing_current("all");
$avgtm = $templatesinserted / (ss_timing_current("all") / 60);
print "<BR><font size='3' color='BLACK'>Templates per second={$avgts}<BR>";
print "<font size='3' color='BLACK'>Templates per minute={$avgtm}<BR>";
コード例 #4
0
$patternsinserted = 0;
$depth = array();
$whaton = "";
$pattern = "";
$topic = "";
$that = "";
$template = "";
$startupwhich = "";
$splitterarray = array();
$inputarray = array();
$genderarray = array();
$personarray = array();
$person2array = array();
loadstartup();
makesubscode();
print "<font size='3' color='RED'><b>DONE LOADING</B><br /></font>\n";
print "<font size='3' color='BLUE'>Inserted {$templatesinserted} categories into database</font><br />\n";
print "<font size='3' color='BLUE'>Inserted {$patternsinserted} sentences into database</font><br /><br />\n";
print "<font size='3' color='RED'><b>WARNING!</b> You should either delete or rename the botloader.php and botloaderinc.php scripts, otherwise people may be able to abuse your server.</b></font>\n";
print "<p><font size='3' color='BLACK'><a href='talk.php'>Click here to talk to the bot</a></p></font>\n";
print "<br />";
ss_timing_stop("all");
print "<br /><br /><font size='3' color='BLACK'>execution time: " . ss_timing_current("all");
$avgts = round($templatesinserted / ss_timing_current("all"));
$avgtm = round($templatesinserted / (ss_timing_current("all") / 60));
print "<br /><font size='3' color='BLACK'>Templates per second={$avgts}<br />";
print "<font size='3' color='BLACK'>Templates per minute={$avgtm}<br />";
$avgps = round($patternsinserted / ss_timing_current("all"));
$avgpm = round($patternsinserted / (ss_timing_current("all") / 60));
print "<font size='3' color='BLACK'>Patterns per second={$avgps}<br />";
print "<font size='3' color='BLACK'>Patterns per minute={$avgpm}<br />";
コード例 #5
0
ファイル: tester.php プロジェクト: aparaschivoiu/webapp
 * @version 0.0.8
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package Interpreter
 * @subpackage Responder
 */
/**
* Include the guts of the program.
*/
include "respond.php";
// Read tests.txt into an array, each line a different element.
$tests = array("testatomic", "testdisplayset", "testhide", "testget", "testsetx", "testalter", "testsettopic", "test6a", "test6b", "testsimplecondition", "testsimpleconditiona", "testsimpleconditionmatch", "testconditionlist", "testconditionlistmatch", "testconditionlistdefault", "testconditionlistname", "teststar test passed", "teststar Test passed one and Test passed two and Test passed three and Test passed four", "testunderscore Test passed one and Test passed two and Test passed three and Test passed four", "testrandom", "testwordformat", "testnestedwordformat", "testsimplemultisentencethat", "testarray4multisentencethat", "testarray3multisentencethat", "testarray2multisentencethat", "testarray1multisentencethat", "testthatarray", "testbotproperties", "testconditionsetvalue", "testnestedcondition", "testnestedcondition1", "testnestedcondition2", "testsetcondition", "testversion", "testsrai", "testsr sraisucceeded", "testnestedsrai", "testthinksrai", "teststarset test passed", "testidsizedate", "testgossip", "testname", "testinput", "testinput1", "testinput2", "testinput3", "testgender he", "testthatstar", "testthatstar1", "testmultithatstar", "testmultithatstar1", "testtopicstar", "testmultitopicstar", "test35", "testoldtopic", "test36", "testextremesrai", "testperson i was", "testperson2 with you");
ss_timing_start("alll");
// For each element in the array to a curl request to talk.php.
for ($x = 0; $x < sizeof($tests); $x++) {
    // Start the session or get the existing session.
    session_start();
    $myuniqueid = session_id();
    // Timer will let us know how long it took to get our response.
    ss_timing_start("single");
    // Here is where we get the reply.
    $botresponse = reply($tests[$x], $myuniqueid, 1);
    // Stop the timer.
    ss_timing_stop("single");
    // Print the results.
    print "<B>RESPONSE: " . $botresponse->response . "<BR></b>";
    print "<BR><BR>execution time: " . ss_timing_current("single");
    print "<BR>";
}
ss_timing_stop("alll");
print "<BR><BR>all execution time: " . ss_timing_current("alll");
print "<BR>";