<?php
function you_me_map($input) {
// Convert the string into a word array
$inputArr = explode(" ", $input);
// Call the you_me function on each element in the array
$inputArr = array_map(you_me, $inputArr);
// Put the array back together as a string and return it.
return implode(" ", $inputArr);
}
function you_me($word) {
switch($word) {
case "i":
case "me":
return "you";
case "you":
return "me";
case "my":
return "your";
case "your":
return "my";
case "yours":
return "mine";
case "mine":
return "yours";
case "am":
return "are";
default:
return $word;
}
}
function wword($word_count) {
$qWord = array("when", "why", "where", "how");
return $qWord[$word_count % 4];
}
function verbp($input) {
$verbs = array("go", "have", "be", "try", "eat", "take", "help",
"make", "get", "jump", "write", "type", "fill", "put", "turn",
"compute", "think", "drink", "blink", "crash", "crunch", "add");
$arr = array_intersect($verbs, explode(" ", $input));
if(sizeof($arr) > 0)
return array_shift($arr);
else
return false;
}
function wpred($input) {
$pred = array("why", "where", "when", "what", "which", "how");
$arr = array_intersect($pred, explode(" ", $input));
if(sizeof($arr) > 0)
return array_shift($arr);
else
return false;
}
function dpred($input) {
$pred = array("do", "can", "should", "would");
$arr = array_intersect($pred, explode(" ", $input));
if(sizeof($arr) > 0)
return array_shift($arr);
else
return false;
}
function punt($punt_count) {
$punt = array("Please go on.", "Tell me more.", "I see.",
"What does that indicate?", "But why be concerned about it?",
"Just tell me how you feel.");
return $punt[$punt_count % 6];
}
?>