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.php
<? include_once "utf8/utf8.class.php"; header("Content-Type: application/xml"); /**************************** MAIN *************************/ global $verbstem; echo '<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet href="conjugate.xsl" 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."); } } 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."); } $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."); } } 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) { $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>"; if($form == "intrans") { $verb_table = "$xfst_path -e 'echo <conjugation>' "; $verb_table .= " -e 'echo <tense tense=\"present\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-pres.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down 3plS-".$word."-pres.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"future\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-fut.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down 3plS-".$word."-fut.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"conditional\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-cond.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down 3plS-".$word."-cond.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"perfect\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down compl+3sgS-".$word."-perfv.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down compl+3plS-".$word."-perfv.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"pluperfect\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down compl+3sgS-".$word."-pluperfv.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down compl+3plS-".$word."-pluperfv.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"optative\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down opt= 3sgS-".$word."-opt.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down opt= 3plS-".$word."-opt.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"imperative\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down imp-".$word."-imp.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down imp-".$word."-imp.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"durative\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-dur.pres.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-dur.pres.pl'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo <tense tense=\"durative\"> '"; $verb_table .= " -e 'echo <verbform type=\"singular\">'"; $verb_table .= " -e 'apply down 3sgS-".$word."-to.go.along.doing-pres.sg'"; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo <verbform type=\"plural\">'"; $verb_table .= " -e 'apply down 3plS-".$word."-to.go.along.doing-pres.pl' "; $verb_table .= " -e 'echo </verbform>'"; $verb_table .= " -e 'echo </tense>'"; $verb_table .= " -e 'echo </conjugation>' -stop"; } else if ($form == "trans") { $verb_table = "$xfst_path -e 'apply down 3sgS-3sgO-".$word."-pres.sg'"; $verb_table .= " echo '<row> <cell>'"; $verb_table .= " -e 'apply down 3plS-3sgO-".$word."-pres.pl'"; $verb_table .= " echo '</row> </cell> <row><cell>'"; $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("<BR>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.<BR>"); } unset($parse); exec($verb_table,$parse); while(list($key,$val) = each($parse)) { //$parse[$key] = utf8_decode($val); $parse[$key] = $utfConverter->utf8ToStr($val); } /* $table .= "<tr><td>Present</td><td>".$parse[1]."</td><td>".$parse[2]."</td><tr>"; $table .= "<tr><td>Future</td><td>".$parse[3]."</td><td>".$parse[4]."</td><tr>"; $table .= "<tr><td>Conditional</td><td>".$parse[5]."</td><td>".$parse[7]."</td><tr>"; $table .= "<tr><td>Conditional</td><td>".$parse[6]."</td><td>".$parse[8]."</td><tr>"; $table .= "<tr><td>Perfective</td><td>".$parse[9]."</td><td>".$parse[10]."</td><tr>"; $table .= "<tr><td>Pluperfective</td><td>".$parse[11]."</td><td>".$parse[12]."</td><tr>"; $table .= "<tr><td>Imperfective</td><td>".$parse[13]."</td><td>".$parse[14]."</td><tr>"; $table .= "<tr><td>Optative</td><td>".$parse[15]."</td><td>".$parse[16]."</td><tr>"; $table .= "<tr><td>Imperative</td><td>".$parse[17]."</td><td>".$parse[18]."</td><tr>"; $table .= "<tr><td>Durative</td><td>".$parse[19]."</td><td>".$parse[20]."</td><tr>"; $table .= "<tr><td>Associated Motion</td><td>".$parse[21]."</td><td>".$parse[22]."</td><tr>"; */ //echo "Here is the Result"; $i=0; //Move these declarations later $lastLine; $currentLine; $xml; foreach($parse as $p) { $i=$i+1; $currentLine = $p; $lasttype; if ($i > 3){ //if(strrchr($currentLine,'type=')==true){ if (strrchr($lastline,'type="plural"')==true){ $lasttype = "type =\"plural\" "; } if(strrchr($lastline,'type="singular"')==true){ $lasttype = "type =\"singular\" "; } //} if(strrchr($lastLine,"<")==false && strrchr($lastline,">")==false ){ if(strrchr($currentLine,"<")==false && strrchr($currentLine,">")==false ){ if($currentLine != ""){ //$currentLine = "</verbform><verbform $lasttype>$p"; $p = "</verbform><verbform $lasttype>$p"; } } } //echo utf8_decode($p); //$xml = $xml . utf8_decode($currentLine); $xml = $xml . utf8_decode($p); $lastLine = $p; } } /* $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; /* $table .= "<tr><td>Present</td><td>".$parse[3]."</td><td>".$parse[4]."</td><tr>"; $table .= "<tr><td>Future</td><td>".$parse[5]."</td><td>".$parse[6]." <i>or</i> ".$parse[7]."</td><tr>"; $table .= "<tr><td>Conditional</td><td>".$parse[8]."<i> or </i>".$parse[9]; $table .= "</td><td>".$parse[10]."<i> or </i>".$parse[11]."</td><tr>"; $table .= "<tr><td>Perfective</td><td>".$parse[12]."</td><td>".$parse[13]."</td><tr>"; $table .= "<tr><td>Pluperfective</td><td>".$parse[14]."</td><td>".$parse[15]."</td><tr>"; $table .= "<tr><td>Imperfective</td><td>".$parse[16]."</td><td>".$parse[17]."</td><tr>"; $table .= "<tr><td>Optative</td><td>".$parse[18]."</td><td>".$parse[19]."</td><tr>"; $table .= "<tr><td>Imperative</td><td>".$parse[20]."</td><td>".$parse[21]."</td><tr>"; $table .= "<tr><td>Durative</td><td>".$parse[22]."<i> or </i> ".$parse[23]."</td><td>".$parse[24]."<i> or </i> ".$parse[25]."</td><tr>"; $table .= "<tr><td>Associated Motion</td><td>".$parse[26]."</td><td>".$parse[27]."<i> or </i> ".$parse[28]."</td>"; */ //******************************************************************************************************************* //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>"; }*/ } //echo $xml; ?>