// remove the ^ marker $cgword = preg_replace("/\\^/", "", $cgword); // differentiate slashes marking alternative lemmas from those marking the surface form $cgword = preg_replace("/>\\//", "> %", $cgword); // start building a html table echo "<table><tr><td colspan=\"2\">Sentence " . $sentence_no . "</td></tr>"; $sentence_no++; foreach ($cgword as $cglemma) { // split each surface word chunk at the following slash $cglemma = preg_split("/\\//", $cglemma); // replace angle brackets, so that we can see them without having to use htmlentities() $cglemma = preg_replace("/</", " {", $cglemma); $cglemma = preg_replace("/>/", "}", $cglemma); // we need to write these out in full to avoid highlighting applying to (eg) "n"s inside words // most (except n) are currently written back by the colourme function, but they don't need to be // n needs to come before prn $cglemma = preg_replace("/{n}/", "{noun}", $cglemma); $cglemma = preg_replace("/{pr}/", "{preposition}", $cglemma); $cglemma = preg_replace("/{prn}/", "{pronoun}", $cglemma); $cglemma = preg_replace("/} {/", ", ", $cglemma); // put multiple lemmas on separate lines to ease reading $cglemma = preg_replace("/ %/", "<br />", $cglemma); $cglemma = preg_replace("/\\+/", "<br />+ ", $cglemma); // format the surface word, and colourise the lemmas; write them into the table $lttablerow = "<tr><td width=\"30%\"><b>" . $cglemma[0] . "</b></td><td>" . colourme($cglemma[1]) . "</td></tr>"; echo $lttablerow; } // close off the table echo "</table>"; } }
// differentiate slashes marking alternative lemmas from those marking the surface form - required? $pretransferword = preg_replace("/>\\//", "> ~", $pretransferword); // start building a html table echo "<table><tr><td colspan=\"2\">Sentence " . $sentence_no . "</td></tr>"; $sentence_no++; foreach ($pretransferword as $pretransferlemma) { // replace angle brackets, so that we can see them without having to use htmlentities() $pretransferlemma = preg_replace("/</", " [", $pretransferlemma); $pretransferlemma = preg_replace("/>/", "]", $pretransferlemma); // we need to write these out in full to avoid highlighting applying to (eg) "n"s inside words // most (except n) are currently written back by the colourme function, but they don't need to be // n needs to come before prn $pretransferlemma = preg_replace("/\\[n\\]/", "[noun]", $pretransferlemma); $pretransferlemma = preg_replace("/\\[pr\\]/", "[preposition]", $pretransferlemma); $pretransferlemma = preg_replace("/\\[prn\\]/", "[pronoun]", $pretransferlemma); $pretransferlemma = preg_replace("/\\] \\[/", ", ", $pretransferlemma); // split lemma off from POS info $pretransferlemma = preg_split("/ \\[/", $pretransferlemma); // remove the trailing } $pretransferlemma = preg_replace("/\\]/", "", $pretransferlemma); // put multiple lemmas on separate lines to ease reading - required for tagger? $pretransferlemma = preg_replace("/ ~/", "<br />", $pretransferlemma); $pretransferlemma = preg_replace("/\\+/", "<br />+ ", $pretransferlemma); // format the surface word, and colourise the lemmas; write them into the table $lttablerow = "<tr><td width=\"30%\"><b>" . $pretransferlemma[0] . "</b></td><td>" . colourme($pretransferlemma[1]) . "</td></tr>"; echo $lttablerow; } // close off the table echo "</table>"; } }
$sentence_no++; foreach ($transferword as $transferlemma) { // replace angle brackets, so that we can see them without having to use htmlentities() $transferlemma = preg_replace("/</", " [", $transferlemma); $transferlemma = preg_replace("/>/", "]", $transferlemma); // we need to write these out in full to avoid highlighting applying to (eg) "n"s inside words // most (except n) are currently written back by the colourme function, but they don't need to be // n needs to come before prn $transferlemma = preg_replace("/\\[n\\]/", "[noun]", $transferlemma); $transferlemma = preg_replace("/\\[pr\\]/", "[preposition]", $transferlemma); $transferlemma = preg_replace("/\\[prn\\]/", "[pronoun]", $transferlemma); $transferlemma = preg_replace("/\\] \\[/", ", ", $transferlemma); // put multiple lemmas on separate lines to ease reading //$transferlemma=preg_replace("/ ~/", "<br />", $transferlemma); $transferlemma = preg_replace("/\\+/", "<br />+ ", $transferlemma); // make the output easier to read //$transferlemma=preg_replace("/\[/", " --- ", $transferlemma); $transferlemma = preg_replace("/\\]/", "", $transferlemma); // split the strings - regexes don't work as well for this as the simpler explode() $transferlemma = explode('{', $transferlemma); $pos = explode('[', $transferlemma[0]); $transferlemma[1] = preg_replace("/\\\$ /", "<br />", $transferlemma[1]); $transferlemma[1] = preg_replace("/\\[/", " --- ", $transferlemma[1]); // format and colourise the info; write it into the table $lttablerow = "<tr><td width=\"20%\"><b>" . $pos[0] . "</b></td><td width=\"40%\">" . $pos[1] . "</td><td width=\"40%\">" . colourme($transferlemma[1]) . "</td></tr>"; echo $lttablerow; } // close off the table echo "</table>"; } }
$sentence_no++; foreach ($interchunkword as $interchunklemma) { // replace angle brackets, so that we can see them without having to use htmlentities() $interchunklemma = preg_replace("/</", " [", $interchunklemma); $interchunklemma = preg_replace("/>/", "]", $interchunklemma); // we need to write these out in full to avoid highlighting applying to (eg) "n"s inside words // most (except n) are currently written back by the colourme function, but they don't need to be // n needs to come before prn $interchunklemma = preg_replace("/\\[n\\]/", "[noun]", $interchunklemma); $interchunklemma = preg_replace("/\\[pr\\]/", "[preposition]", $interchunklemma); $interchunklemma = preg_replace("/\\[prn\\]/", "[pronoun]", $interchunklemma); $interchunklemma = preg_replace("/\\] \\[/", ", ", $interchunklemma); // put multiple lemmas on separate lines to ease reading //$interchunklemma=preg_replace("/ ~/", "<br />", $interchunklemma); $interchunklemma = preg_replace("/\\+/", "<br />+ ", $interchunklemma); // make the output easier to read //$interchunklemma=preg_replace("/\[/", " --- ", $interchunklemma); $interchunklemma = preg_replace("/\\]/", "", $interchunklemma); // split the strings - regexes don't work as well for this as the simpler explode() $interchunklemma = explode('{', $interchunklemma); $pos = explode('[', $interchunklemma[0]); $interchunklemma[1] = preg_replace("/\\\$ /", "<br />", $interchunklemma[1]); $interchunklemma[1] = preg_replace("/\\[/", " --- ", $interchunklemma[1]); // format and colourise the info; write it into the table $lttablerow = "<tr><td width=\"20%\"><b>" . $pos[0] . "</b></td><td width=\"40%\">" . $pos[1] . "</td><td width=\"40%\">" . colourme($interchunklemma[1]) . "</td></tr>"; echo $lttablerow; } // close off the table echo "</table>"; } }