strToUtf8($word);
$xfst_path = "/spd25/htdocs/hyperlex2/nahuatl/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'";
$command = $xfst_path." -e 'apply up $word' -stop";
unset($parse);
exec($command,$parse);
//$result = utf8_decode(trim($parse[3]));
$result = $utfConverter->utf8ToStr(trim($parse[3]));
if($result != "") {
$command = "/spd25/htdocs/hyperlex2/nahuatl/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm'";
//$command = "xfst -utf8 -e 'loadd SurfaceForms.fsm'";
$command .= " -e 'regex GlUR;' -e 'apply down $result' -stop";
unset($parse);
$foo = exec($command,$parse);
$temp = $parse[3];
/*
foreach($parse2 as $p) {
echo utf8_decode($p)."
";
}
*/
if($temp != "") {
echo "";
echo "Parse: $temp ";
echo "";
}
echo "";
echo "Gloss: $result ";
echo "";
$parts = explode("-",$result);
$index = count($parts)-2;
$results[0] = $parts[$index];
echo "";
echo "Verb stem: ".$results[0]."";
echo "";
//$verbstem = $results[0];
echo $verbstem;
if($index == 1) {
echo "";
$results[1] = "intrans";
echo "Part of speech: Intransitive Oapan verb";
echo "";
}
else if($index == 2) {
echo "";
$results[1] = "trans";
echo "Part of speech: Transitive Oapan verb";
echo "";
}
return $results;
}
return "";
}
function display_verb_table($word, $form)
{
$word = strtolower($word);
$word = utf8_encode($word);
$utfConverter = new utf8(); //defaults to CP1250.
$word = $utfConverter->strToUtf8($word);
$xfst_path = "/spd25/htdocs/hyperlex2/nahuatl/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'";
unset($table);
$table = "Tense/AspectSingularPlural";
if($form == "intrans")
{
$verb_table = "$xfst_path -e 'apply down 3sgS-".$word."-pres.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-pres.pl'";
$verb_table .= " -e 'apply down 3sgS-".$word."-fut.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-fut.pl'";
$verb_table .= " -e 'apply down 3sgS-".$word."-cond.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-cond.pl'";
$verb_table .= " -e 'apply down compl+3sgS-".$word."-perfv.sg'";
$verb_table .= " -e 'apply down compl+3plS-".$word."-perfv.pl'";
$verb_table .= " -e 'apply down compl+3sgS-".$word."-pluperfv.sg'";
$verb_table .= " -e 'apply down compl+3plS-".$word."-pluperfv.pl'";
$verb_table .= " -e 'apply down 3sgS-".$word."-imperfv.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-imperfv.pl'";
$verb_table .= " -e 'apply down opt= 3sgS-".$word."-opt.sg'";
$verb_table .= " -e 'apply down opt= 3plS-".$word."-opt.pl'";
$verb_table .= " -e 'apply down imp-".$word."-imp.sg'";
$verb_table .= " -e 'apply down imp-".$word."-imp.pl'";
$verb_table .= " -e 'apply down 3sgS-".$word."-dur.pres.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-dur.pres.pl'";
$verb_table .= " -e 'apply down 3sgS-".$word."-to.go.along.doing-pres.sg'";
$verb_table .= " -e 'apply down 3plS-".$word."-to.go.along.doing-pres.pl' -stop";
}
else if ($form == "trans")
{
$verb_table = "$xfst_path -e 'apply down 3sgS-3sgO-".$word."-pres.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-pres.pl'";
$verb_table .= " -e 'apply down 3sgS-3sgO-".$word."-fut.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-fut.pl'";
$verb_table .= " -e 'apply down 3sgS-3sgO-".$word."-cond.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-cond.pl'";
$verb_table .= " -e 'apply down compl+3sgS-3sgO-".$word."-perfv.sg'";
$verb_table .= " -e 'apply down compl+3plS-3sgO-".$word."-perfv.pl'";
$verb_table .= " -e 'apply down compl+3sgS-3sgO-".$word."-pluperfv.sg'";
$verb_table .= " -e 'apply down compl+3plS-3sgO-".$word."-pluperfv.pl'";
$verb_table .= " -e 'apply down 3sgS-3sgO-".$word."-imperfv.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-imperfv.pl'";
$verb_table .= " -e 'apply down opt= 3sgS-3sgO-".$word."-opt.sg'";
$verb_table .= " -e 'apply down opt= 3plS-3sgO-".$word."-opt.pl'";
$verb_table .= " -e 'apply down imp-3sgO-".$word."-imp.sg'";
$verb_table .= " -e 'apply down imp-3sgO-".$word."-imp.pl'";
$verb_table .= " -e 'apply down 3sgS-3sgO-".$word."-dur.pres.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-dur.pres.pl'";
$verb_table .= " -e 'apply down 3sgS-3sgO-".$word."-to.go.along.doing-pres.sg'";
$verb_table .= " -e 'apply down 3plS-3sgO-".$word."-to.go.along.doing-pres.pl' -stop";
}
else {
die("
For the moment, a verb table can not be generated from this page. Please click on root verb and generate the inflectional table directly from the dictionary entry.
");
}
unset($parse);
exec($verb_table,$parse);
while(list($key,$val) = each($parse)) {
//$parse[$key] = utf8_decode($val);
$parse[$key] = $utfConverter->utf8ToStr($val);
}
/*
$table .= "Present".$parse[1]."".$parse[2]."";
$table .= "Future".$parse[3]."".$parse[4]."";
$table .= "Conditional".$parse[5]."".$parse[7]."";
$table .= "Conditional".$parse[6]."".$parse[8]."";
$table .= "Perfective".$parse[9]."".$parse[10]."";
$table .= "Pluperfective".$parse[11]."".$parse[12]."";
$table .= "Imperfective".$parse[13]."".$parse[14]."";
$table .= "Optative".$parse[15]."".$parse[16]."";
$table .= "Imperative".$parse[17]."".$parse[18]."";
$table .= "Durative".$parse[19]."".$parse[20]."";
$table .= "Associated Motion".$parse[21]."".$parse[22]."";
*/
$table .= "Present".$parse[3]."".$parse[4]."";
$table .= "Future".$parse[5]."".$parse[6]." or ".$parse[7]."";
$table .= "Conditional".$parse[8]." or ".$parse[9];
$table .= "".$parse[10]." or ".$parse[11]."";
$table .= "Perfective".$parse[12]."".$parse[13]."";
$table .= "Pluperfective".$parse[14]."".$parse[15]."";
$table .= "Imperfective".$parse[16]."".$parse[17]."";
$table .= "Optative".$parse[18]."".$parse[19]."";
$table .= "Imperative".$parse[20]."".$parse[21]."";
$table .= "Durative".$parse[22]." or ".$parse[23]."".$parse[24]." or ".$parse[25]."";
$table .= "Associated Motion".$parse[26]."".$parse[27]." or ".$parse[28]."";
//*******************************************************************************************************************
//Not sure what's going on with variable scope, here. When I declare condition is global, it's not read.
// Also, check for $condition switch, this was an unpopulated var, code used old php form data request, must use $_request array.
//*******************************************************************************************************************
$condition = $_REQUEST['condition'];
if ($condition == "story"){
echo "
";
echo "Oapan verb inflections
";
echo "
";
echo "";
echo $table;
echo "";
}else{
echo "
";
echo "Oapan verb inflections
";
echo "
";
echo "";
echo $table;
echo "";
}
}
/**************************** MAIN *************************/
global $verbstem;
if($condition == "story")
{
$word = strtolower($word);
if(ereg("Am",$dialect)) {
//$lxa = $word;
//FOR NOW:
$lxo = $word;
}
else if(ereg("Oa",$dialect)) {
$lxo = $word;
}
$word = $lxo;
echo "";
echo "";
$root_info = get_root_verb($word);
echo "";
echo "Word: | $word ";
echo " |
";
//echo $root_info[0]."adsadas";
echo "
Click to show/hide: Senses / Inflections
";
//echo "
Click to show/hide: Inflections
";
if($root_info == "") {
$xfst_path = "/spd25/htdocs/hyperlex2/nahuatl/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'";
$command = "$xfst_path -e 'apply down 3sgS-3sgO-".$word."-pres.sg' -stop";
unset($parse);
$result = trim(exec($command,$parse));
if($result != "") {
echo "
Oh my God, this may be a transitive verb! If the query did not include an object prefix, please try resubmitting with an object prefix.
If the query did contain a correct object prefix, then this verb is most likely an irregular verb that still does not parse.
";
}
else {
die("This word can not be parsed.");
}
}
else {
display_verb_table($root_info[0],$root_info[1]);
}
$urltoSenses = "http://hyperlex2.ldc.upenn.edu/nahuatl/search_results.php4?user_lang=english&condition=word_search&word=".$root_info[0]."&entry_template=englishwordsense.html&bg_template=english%senses_template.html";
//echo $urltoSenses;
echo "";
}
else
{
$words = strtolower($words);
$words = explode("_",$words);
$lxa = $words[0];
$lxo = $words[1];
//FOR NOW....
$word = $lxo;
if(trim($form) == "") {
$HOST = "wave.ldc.upenn.edu";
$USER = "hyperlex";
$PASSWORD = "jota";
$DATABASE = "hyperlex";
$TABLE = "nahuatl";
@ $db = mysql_pconnect($HOST, $USER, $PASSWORD);
if(!$db) {
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db($DATABASE);
$query = "SELECT psm FROM $TABLE WHERE lxo='$word'";
$query_result = mysql_query($query);
if(mysql_num_rows($query_result) == 0) {
die("$lxo is not in the lexicon.");
}
$row = mysql_fetch_assoc($query_result);
$psm = $row["psm"];
echo "PSM: $psm
";
if(ereg("V0|V1",$psm)) {
$form = "intrans";
}
else if(ereg("V2|V3",$psm)) {
$form = "trans";
}
else {
die("$lxo can not be parsed. Part of speech is $psm. Must have part of speech V0, V1, V2, or V3.");
}
}
//This is strange, it was written with a body that apears when it's not part of the story
echo "";
display_verb_table($word,$form);
echo "";
}
?>