function parseSentence($req) { //get responses from the last 5 minutes... //these cconversations contain context //gives an output... but has to determine if there is a context //if contains and it if (!isset($req['sentence'])) { return array("status" => "fail", "msg" => "please send sentence"); } $sent = $req['sentence']; $n_words = preg_match_all('/([a-zA-Z]|\\xC3[\\x80-\\x96\\x98-\\xB6\\xB8-\\xBF]|\\xC5[\\x92\\x93\\xA0\\xA1\\xB8\\xBD\\xBE]){4,}/', $sent, $match_arr); $word_arr = $match_arr[0]; foreach ($word_arr as $i => $val) { $word_arr[$i] = strtolower($word_arr[$i]); } //get parts of sentence $sentParts = explode(",", $sent); if (!isset($sentParts[1])) { $sentParts[1] = null; } else { $sentParts[0] = $sent; } $resp = checkForQuestion($sent); if ($resp == true) { $resp = answerQuestion($sentParts[0], $sentParts[1], $sent); //echo("is a question"); return "question"; } else { //echo("is not a question"); //return false; } if (checkCommand($sent) == true) { //echo('is a command'); return "command"; } else { //echo("is not command"); //return false; } if (checkExclamation($sent) == true) { //echo('is a exclamation'); return "exclamation"; } else { //echo("is not exclamation"); //return false; } return "declaration"; //question //bot should determine kind of question //what //determine if first word is one of these, or if one of these comes after a comma //send sentence to question //exclamation //bot should determine if this is excited conversational speak or command //go to end of sentence and check for an emoticon or an exclamation mark //command //bot should determine what the command it //determine if first word can be used as a verb... and if there are no other words being used as a verb, then this is command. Also, it should be a present tense.... or if this comes after a comma, like first, do this... //declaration //response should be conversational }
echo "\"{$testQuery}\", No, No, NA.<br>"; } } } answerQuestion("How long should I breastfeed my child for ?"); answerQuestion("What allah loves ?"); answerQuestion("What are the attributions of Allah ?"); answerQuestion("When was the Quran Revealed ?"); answerQuestion("Animals in the Quran ?"); answerQuestion("How many signs were sent to pharaoh ?"); answerQuestion("What did Allah said to Adam ?"); answerQuestion("What are the colors in the Quran ?"); answerQuestion("Who is the prophet whom Allah spoke to ?"); answerQuestion("Fruits in Heaven ?"); answerQuestion("Number of wives allowed in Islam ?"); answerQuestion("Who are the people of the Book ?"); ?> <div id="loading-layer"> Loading ... </div> </div> <script type="text/javascript"> $(document).ready(function()