include_once "utf8/utf8.class.php"; header("Content-Type: application/xml"); //header("Content-Type: text"); /**************************** MAIN *************************/ global $verbstem; echo ' '; 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; $root_info = get_root_verb($word); if($root_info == "") { //$xfst_path = "/spd25/htdocs/hyperlex2/nahuatl/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'"; $xfst_path = "/home/cust1/user1121861/html/php/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."); echo "This word can not be parsed."; die (""); } } 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"; } else { //$words = strtolower($words); $words = strtolower($_GET["words"]); $words = explode("_",$words); $lxa = $words[0]; $lxo = $words[1]; //FOR NOW.... $word = $lxo; if(trim($form) == "") { $HOST = "216.247.255.141"; $USER = "user1121861"; $PASSWORD = "pcw6zmeqhy"; $DATABASE = "balsas_nahuatlorg"; //$TABLE = "nahuatl"; $TABLE = "refgroup"; @ $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_0 FROM $TABLE WHERE lxo_0='$word'"; //$query = "SELECT * FROM $TABLE WHERE lxo_0='$word'"; //$query = "SELECT * FROM refgroup "; $query_result = mysql_query($query); if(mysql_num_rows($query_result) == 0) { die("$lxo is not in the lexicon."); //echo "$lxo is not in the lexicon."; die (""); } $row = mysql_fetch_assoc($query_result); //$psm = $row["psm_0"]; //debug code: //echo "$row[0]|$row[1]|$row[2]|$row[3]|$row[4]"; $psm = $row["psm_0"]; //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."); //$form="trans"; echo "$lxo can not be parsed. Part of speech is $psm. Must have part of speech V0, V1, V2, or V3."; die(""); } } display_verb_table($word,$form); } function get_root_verb($word){ $word = strtolower($word); //$word = utf8_encode($word); $utfConverter = new utf8(); $word = $utfConverter->strToUtf8($word); $xfst_path = "/home/cust1/user1121861/html/php/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'"; //$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 = "/home/cust1/user1121861/html/php/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); //echo "Here it is$parse[3]"; $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) { $i=0; $lasttype; $lastLine; $lastNumber; $xml; $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;'"; $xfst_path = "/home/cust1/user1121861/html/php/xfst_dir/xfst -utf8 -e 'loadd SurfaceForms.fsm' -e 'regex GlSR;'"; unset($table); //$table = "Tense/AspectSingularPlural"; $strTransAdder = ""; if($form == "intrans"){ $strTransAdder=""; }else if($form == "trans" ){ $strTransAdder = "3sgO-"; }else{ //$xml = "ooops"; //$verb_table = "$xfst_path -e 'ooops'"; echo ""; echo "For the moment, a verb table cannot be generated from this page. Please click on root verb and generate the inflectional table directly from the dictionary entry."; echo ""; die (""); } $verb_table = "$xfst_path -e 'echo ' "; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-pres.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-pres.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-fut.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-fut.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-cond.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-cond.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down compl+3sgS-$strTransAdder".$word."-perfv.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down compl+3plS-$strTransAdder".$word."-perfv.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down compl+3sgS-$strTransAdder".$word."-pluperfv.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down compl+3plS-$strTransAdder".$word."-pluperfv.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-imperfv.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-imperfv.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down opt= 3sgS-$strTransAdder".$word."-opt.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down opt= 3plS-$strTransAdder".$word."-opt.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down imp-$strTransAdder".$word."-imp.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down imp-$strTransAdder".$word."-imp.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-dur.pres.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-dur.pres.pl'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-to.go.along.doing-pres.sg'"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-to.go.along.doing-pres.pl' "; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo '"; $verb_table .= " -e 'echo ' -stop"; unset($parse); exec($verb_table,$parse); while(list($key,$val) = each($parse)) { //$parse[$key] = utf8_decode($val); $parse[$key] = $utfConverter->utf8ToStr($val); } //Move these declarations later foreach($parse as $p) { $i=$i+1; $currentLine = ""; $currentLine = $p; if ($i > 3){ if (strrchr($lastLine,'singular')==true){ $lastNumber = "S"; } if(strrchr($lastLine,'plural')==true){ $lastNumber = "P"; } if(strrchr($p,"<")==false && strrchr($p,">")==false ){ if(trim($p) != ""){ if($lastNumber == "S"){ $p = "$p"; }else if($lastNumber == "P"){ $p = "$p"; } } } $xml = $xml . utf8_decode($p); $lastLine = $p; } } /*For later use - server side transform $xsl = simplexml_load_file('conjugate.xsl'); $arguments = array( '/_xml' => $xml, '/_xsl' => $xsl ); $xh = xslt_create(); //$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); echo $result; $xh = xslt_free(); */ echo $xml; //******************************************************************************************************************* //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 ""; }*/ } ?>