include_once("json.php");
$lang = "EN";
$iFrom = intval($_REQUEST['from']);
$iTo = intval($_REQUEST['to']);
if (isset($_REQUEST['split']))
$split = $_REQUEST['split'];
else
$split = 'dev';
$perpage = intval($_REQUEST['perpage']);
if ($perpage<=0)
$perpage = 10;
if (array_key_exists("submit", $_REQUEST)) { // save data from a page of annotation
$LOG_FILE = "$split.annotation.log";
$TAG_FILE = "$split.annotation.tags";
$logF = fopen($LOG_FILE, 'a');
$tagF = fopen($TAG_FILE, 'a');
if (!$logF || !$tagF) die("Unable to save annotations in files in " . getcwd());
fwrite($logF, htmlspecialchars_decode(stripslashes($_REQUEST['resultsLog']), ENT_QUOTES));
fwrite($tagF, htmlspecialchars_decode(stripslashes($_REQUEST['resultsTags']), ENT_QUOTES));
fclose($logF);
fclose($tagF);
}
($iFrom>=0 && $iTo>$iFrom) or die("You have finished annotating the current batch. Thanks!");
$IN_FILE = "$split.automatic_tags";
$f = fopen($IN_FILE, 'r');
// The sentences. Word tokens are space-separated and have default tags.
// $SENTENCES = array('Mark/^ Owens/^ will/M be/V chairing/V the/D session/N with/P Dr./^ Phelps/^ ./,',
// 'Down/N is/V neither/X as/P warm/A as/P fur/N ,/, nor/X as/P expensive/A ./,');
$SENTENCES = array();
if ($f) {
$l = 0;
while (($entry = fgets($f)) !== false) {
if ($l >= $iFrom) {
if ($l >= $iTo || $l >= ($iFrom+$perpage)) break;
$entry = htmlspecialchars($entry, ENT_QUOTES);
$entry = explode("\t", $entry);
$twitterId = $entry[0];
$tokenizedS = $entry[1];
$tagsS = $entry[2];
$metadata = "$twitterId " . join("@@", array_slice($entry, 3)); //json_indent($entry[3]);
$tokens = explode(' ', $tokenizedS);
$tags = explode(' ', $tagsS);
$taggedS = "";
for ($i=0; $i