SET WORD CLASS AND SET CODE FILE // // IF NOUNS if ($_GET['word_class'] == "inoun") { $word_class = 'N'; $codes = "noun-codes.txt"; } // IF INTRANSITIVE VERBS elseif ($_GET['word_class'] == "iverb") { $word_class = 'V'; $codes = "intrans-codes.txt"; } // IF TRANSITIVE VERBS elseif ($_GET['word_class'] == "tverb") { $word_class = 'V'; $codes = "trans-codes.txt"; } // IF PRONOUNS elseif ($_GET['word_class'] == "pronoun") { $word_class = 'Pron'; $codes = "pron-codes.txt"; } // ELSE DO NOTHING! else { // particle $word_class = 'P'; $codes = "pron-codes.txt"; } ?> \*\|`&\$!#\(\)\[\]\{\}:\'\"]/',' ',$text); $text = preg_replace('/\?/',' ?',$text); // make space before question marks (?) $text = preg_replace('/\./',' .',$text); // make space before dot (.) $text = preg_replace('/\,/',' ,',$text); // make space before (,) // split the text into words crudely on spaces $words = preg_split('/\s+/', $text) ; // if we reach here, then the user did indeed one or more words; // join the words back into a single string // each remaining word now separated by spaces $allwords = implode(" ", $words) ; // // And here is where the actual generating gets done: // //************************************************************** //************************************************************** // VARIABLE DEFINITIONS // ==================== // Where all the Xerox binaries are: $xfstdir = $global['PATH_TO_XEROX']; // Where all the Xerox binaries are: $xfst = $global['XEROX_VERSION']; // Where all the perl scripts are: // $bindir = $global['PATH_TO_SCRIPTS']; // Directory where all the compiled fst's are: $fstdir = $global['PATH_TO_FST_BIN'] ; // Directory for the source files (which compile into fst's): $srcdir = $global['PATH_TO_FST_SRC']; // The temp directory: $temp = $global['PATH_TO_TMP']; // Input files with inflectional tags: $fstrules = $global['PATH_TO_FST_RULES'] ; // Directory where all the compiled paradigms' are: $paradigmdir = $global['PATH_TO_PARADIGM_FILES'] ; // This variable is holding the filename of the save file: $savefile = $fstdir."/kal.save"; // FORM SPECIFIC SECTIONS // ===================== // WORD IN PUBLIC FORM $fst = $fstdir . "/kal.fst"; // Linguistic tags include($global['PATH_TO_ANALYSE']); $word = $an_word; // WORD IN BASEFORM //$wordline = preg_split('/\s/', $allwords); //$word = $wordline[0]; // Set baseform $baseform = $word; $filename = "tempfile"; echo "
"; // POS SPECIFIC SECTIONS // ===================== // // Create paradigm generation input file: // /* * Purpose: * * To create a file for testing paradigm generation by combining a tag list * and a word (supposedly the base form). * * ARG1: input file with inflectional tags * ARG2: the base form of the word we want to inflect * * Output file: * * Baseform+tags for all tags given in the tag file * This can directly be given to xfst for word form generation */ $mergefile = file($fstrules.'/'.$codes); $fm = fopen($temp.'/'.$filename.'-para.ptest', "w", 0); foreach ($mergefile as $mergeline) { //$mergefile = chop($mergeline); fputs($fm, $baseform.$mergeline); } fclose($fm); // // Paradigm generation: // $script = "load ".$savefile."\n"."apply down < ".$temp."/$filename-para.ptest \n quit \n"; $fp = fopen($temp.'/'.$filename.'-gtest-script', "w", 0); fputs($fp, $script); fclose($fp); exec("$xfstdir/$xfst < $temp/$filename-gtest-script > $paradigmdir/$filename.paradigm"); // HOUSEKEEPING // ============ exec("rm -f $temp/$filename-para.ptest"); exec("rm -f $temp/$filename-gtest-script"); //************************************************************** //************************************************************** //FILE START if (@file($paradigmdir.'/'.$filename.'.paradigm')) { // Get a file into string: $html = implode('', file($paradigmdir.'/'.$filename.'.paradigm')); // Make a temporary printfile: $pr = fopen($temp.'/'.$filename.'-print', "w", 0); fputs($pr, $html); fclose($pr); // Printing variables: $cnt = 0; $line_cnt = 0; $split = 40; if ($tags == "l") { $width = "300"; } else { $width = "100%"; } ?>
$line) { $line_cnt = $line_cnt+1; } foreach ($lines as $line_num => $line) { if ($line_num == 0) { } else { if ($line_num == ($split+1) | $line_num == (($split*3)+1) | $line_num == (($split*5)+1) | $line_num == (($split*7)+1)) { if ($tags == "l") { echo "
\n\n"; echo "
\n\n"; echo ""; } else { echo "
\n\n"; echo "

\n\n"; echo ""; } } else if ($line_num == (($split*2)+1) | $line_num == (($split*4)+1) | $line_num == (($split*6)+1) | $line_num == (($split*8)+1)) { echo "
\n\n"; echo "

\n\n"; echo ""; } else { } echo ""; $columns = preg_split('/\n/', $line); echo ""; echo ""; echo ""; echo ""; } } ?>
".$line_num."."; $base_tag_form = $columns[0]; include($global['PATH_TO_TAGS']); echo ""; $lastline = preg_split('/\s/', $columns[1]); if ($lastline[0] == "Closing") { } else { echo $columns[1]; } echo "
".$lang['PARADIGM_no_word']; } // // That's all Folks! // ------------------------------------------------- ?> -----------------------------1539548166661214351620291420 Content-Disposition: form-data; name="Compose.Attach.Add.x" 50