Tryag File Manager
Home
-
Turbo Force
Current Path :
/
home
/
cluster1
/
data
/
bu01
/
1121861
/
html
/
xfst_dir_copy
/
Upload File :
New :
File
Dir
/home/cluster1/data/bu01/1121861/html/xfst_dir_copy/conjugate_lg.php
<? include_once "utf8/utf8.class.php"; //header("Content-Type: application/xml"); header("Content-Type: text"); /**************************** MAIN *************************/ global $verbstem; /*echo '<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet href="conjugate.xsl" type="text/xsl"?> '; */ echo '<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet type="text/xsl"?> '; 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;'"; $command = "$xfst_path -e 'apply down 3sgS-3sgO-".$word."-pres.sg' -stop"; unset($parse); $result = trim(exec($command,$parse)); if($result != "") { //echo "<BR>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. <BR><BR>If the query did contain a correct object prefix, then this verb is most likely an irregular verb that still does not parse.<BR>"; } else { //die("This word can not be parsed."); echo "<error>This word can not be parsed.<error>"; 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 = 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."); echo "<error>$lxo is not in the lexicon.<error>"; die (""); } $row = mysql_fetch_assoc($query_result); $psm = $row["psm"]; //echo "PSM: $psm <BR>"; 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."); echo "<error>$lxo can not be parsed. Part of speech is $psm. Must have part of speech V0, V1, V2, or V3.</error>"; 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 = "/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); //echo "Here it is$parse[3]"; $temp = $parse[3]; /* foreach($parse2 as $p) { echo utf8_decode($p)."<BR>"; } */ /*if($temp != "") { echo "<tr><td class=\"descriptor\">"; echo "Parse:</td><td class=\"value\"> $temp "; echo "</tr></td>"; } echo "<tr><td class=\"descriptor\">"; echo "Gloss:</td><td class=\"value\"> $result "; echo "</tr></td>"; */ $parts = explode("-",$result); $index = count($parts)-2; $results[0] = $parts[$index]; /*echo "<tr><td class=\"descriptor\">"; echo "Verb stem: </td><td class=\"value\"><a href='http://hyperlex2.ldc.upenn.edu/nahuatl/search_results.php4?user_lang=english&condition=word_search&word=".$results[0]."' target='dictionary'>".$results[0]."</A>"; echo "</tr></td>"; */ //$verbstem = $results[0]; echo $verbstem; if($index == 1) { //echo "<tr><td class=\"descriptor\">"; $results[1] = "intrans"; //echo "Part of speech: </td><td class=\"value\">Intransitive Oapan verb"; //echo "</tr></td>"; }else if($index == 2) { //echo "<tr><td class=\"descriptor\">"; $results[1] = "trans"; //echo "Part of speech: </td><td class=\"value\">Transitive Oapan verb"; //echo "</tr></td>"; } 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;'"; unset($table); //$table = "<tr><td><b>Tense/Aspect</b></td><td><b>Singular</b></td><td><b>Plural</b></td></tr>"; $strTransAdder = ""; if($form == "intrans"){ $strTransAdder=""; }else if($form == "trans" ){ $strTransAdder = "3sgO-"; }else{ //$xml = "<error>ooops</error>"; //$verb_table = "$xfst_path -e '<error>ooops</error>'"; echo "<error>"; 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.<BR>"; echo "</error>"; die (""); } $verb_table = "$xfst_path -e 'echo <conjugation>' "; $verb_table .= " -e 'echo <tense tense=\"Present\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-pres.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-pres.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Future\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-fut.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-fut.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Conditional\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-cond.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-cond.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Perfective\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down compl+3sgS-$strTransAdder".$word."-perfv.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down compl+3plS-$strTransAdder".$word."-perfv.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Pluperfective\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down compl+3sgS-$strTransAdder".$word."-pluperfv.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down compl+3plS-$strTransAdder".$word."-pluperfv.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Imperfective\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-imperfv.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-imperfv.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Optative\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down opt= 3sgS-$strTransAdder".$word."-opt.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down opt= 3plS-$strTransAdder".$word."-opt.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Imperative\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down imp-$strTransAdder".$word."-imp.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down imp-$strTransAdder".$word."-imp.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Durative\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-dur.pres.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-dur.pres.pl'"; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"Motion Auxillary\"> '"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <singular>'"; $verb_table .= " -e 'apply down 3sgS-$strTransAdder".$word."-to.go.along.doing-pres.sg'"; $verb_table .= " -e 'echo </singular>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform>'"; $verb_table .= " -e 'echo <plural>'"; $verb_table .= " -e 'apply down 3plS-$strTransAdder".$word."-to.go.along.doing-pres.pl' "; $verb_table .= " -e 'echo </plural>'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo </conjugation>' -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) { echo $p; }*/ foreach($parse as $p) { $i=$i+1; $currentLine = ""; $currentLine = $p; //if ($i > 3){ if ($i > 3){ if (strrchr($lastLine,'singular')==true){ $lastNumber = "S"; } if(strrchr($lastLine,'plural')==true){ $lastNumber = "P"; } if(strrchr($p,"<")==false && strrchr($p,">")==false ){ //This is suspect, if(trim($p) != ""){ if($lastNumber == "S" ){ //if (strrchr($currentLine,'singular')==true){ //echo "it is a: ($p)"; $p = "</singular><singular>$p"; //} }else if($lastNumber == "P" ){ $p = "</plural><plural>$p"; } } } $lastLine = $p; $xml = $xml . utf8_decode($p); } } //junk hack to solve empty tag bug $xml=str_replace("<singular></singular>","",$xml); $xml=str_replace("<plural></plural>","",$xml); /*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 "<BR>"; echo "<div id=\"oInflectionsTitle\" style=\"display:none;\"><b>Oapan verb inflections</b></div>"; echo "<BR><BR>"; echo "<table class=\"tblInflections\" id=\"tblInflections\" style=\"display:none;\" border='1' cellpadding='3' cellspacing='3'>"; */ //echo $table; /* echo "</table>"; }else{ echo "<BR>"; echo "<div id=\"oInflectionsTitle\" ><b>Oapan verb inflections</b></div>"; echo "<BR><BR>"; echo "<table class=\"tblInflections\" id=\"tblInflections\" border='1' cellpadding='3' cellspacing='3'>"; echo $table; echo "</table>"; }*/ } ?>