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/verb_forms.php4
<html> <title>NLE:Verb Forms Parser</title> <link href="css/Verb_Forms.css" rel="stylesheet" type="text/css"> <script language="JavaScript"> function ShowMe(strSwitch){ var oLyr; if (strSwitch == "Inflections"){ document.getElementById("Layer1").style.display= 'none'; if (document.getElementById('tblInflections').style.display=="none"){ document.getElementById('tblInflections').style.display= 'block'; document.getElementById('oInflectionsTitle').style.display= 'block'; window.resizeTo(400,700); }else{ document.getElementById('tblInflections').style.display= 'none'; document.getElementById('oInflectionsTitle').style.display= 'none'; window.resizeTo(400,275); } //if (document.getElementById("Layer1").style.display=="block"){ // window.resizeTo(400,900); //}else{ // window.resizeTo(400,700); //} }else{ document.getElementById("tblInflections").style.display= "none"; document.getElementById("oInflectionsTitle").style.display= 'none'; if(document.getElementById("Layer1").style.display=='none'){ document.getElementById("Layer1").style.display= 'block' window.resizeTo(400,700); }else{ document.getElementById("Layer1").style.display= 'none' window.resizeTo(400,275); } } /* if (document.getElementById("Layer1").style.display=="block"){ window.resizeTo(400,500); }else{ window.resizeTo(400,300); } } }else{ //Show senses oLyr = document.getElementById("Layer1"); if(oLyr.style.display == "none"){ oLyr.style.display= "block"; if (document.getElementById("tblInflections").style.display=="block"){ window.resizeTo(400,900); }else{ window.resizeTo(400,700); } }else{ oLyr.style.display = "none"; if (document.getElementById("tblInflections").style.display=="block"){ window.resizeTo(400,500); }else{ window.resizeTo(400,300); } } } */ } function HideSenses(){ var oLyr; oLyr = document.getElementById("Layer1") if (oLyr){ oLyr.style.display="none"; } } function HideSensesLink(){ var oAnchor; oAnchor= document.getElementById("SensesLink") if(oAnchor){ oAnchor.style.display="none"; } } function ShowSensesLink(){ var oAnchor; oAnchor= document.getElementById("SensesLink") if(oAnchor){ oAnchor.style.display="inline"; } } </script> <body> <? include_once "utf8/utf8.class.php"; 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); $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 '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("<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>"; */ $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>"; } } /**************************** 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 "<table class=\"tblVerb\" border = \"1\" cellpadding=\"3\" cellspaceing=\"3\">"; echo "<tr><td class=\"descriptor\">"; echo "Word: </td><td class=\"value\">$word <BR>"; echo "</tr></td>"; $root_info = get_root_verb($word); echo "</table>"; //echo $root_info[0]."adsadas"; echo "<br>Click to show/hide: <a id = \"SensesLink\" href = \"javascript:ShowMe('Senses');\">Senses</a> / <a href = \"javascript:ShowMe('Inflections');\">Inflections</a><br>"; //echo "<br>Click to show/hide: <a href = \"javascript:ShowMe('Inflections');\">Inflections</a><br>"; 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"; //echo $urltoSenses; echo "<div id=\"Layer1\" style=\"display:none;width:360px; height:450px; z-index:1;\"><iframe style=\"scrollbar-base-color:#FFFFcc;\" width = \"355\" height=\"450\" align = \"left\" src=\"$urltoSenses\" scrolling=\"yes\" frameborder=\"0\" ></iframe></div>"; } 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."); } } //This is strange, it was written with a body that apears when it's not part of the story echo "<BODY onload='javascript:window.focus();HideSenses();'>"; display_verb_table($word,$form); echo "</BODY>"; } ?> </body> <script language = "JavaScript"> //Hack to solve slow loading iframe problem in IE if (navigator.appName.indexOf("Microsoft")>=0){ HideSensesLink(); setTimeout(ShowSensesLink,3000); } </script> </html>