"concordiaSearch","tmId" => $tmId,"pattern" => $inputSentence);
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => json_encode($data),
),
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$data = json_decode($response);
function sub($string, $start, $end = null) {
if (is_null($end)) {
return mb_substr($string, $start, null, 'UTF-8');
} else {
return mb_substr($string, $start, $end-$start, 'UTF-8');
}
}
?>
Concordia score: = round($data->result->bestOverlayScore*100) ?>%
result->bestOverlay);$i++) {
$fragment = $data->result->bestOverlay[$i];
//previous unmarked fragment
echo sub($inputSentence,$lastInsertedEnd, $fragment->matchedPatternStart);
//the marked fragment
?>= sub($inputSentence,$fragment->matchedPatternStart, $fragment->matchedPatternEnd) ?>matchedPatternEnd;
//fragments += renderFragment(fragment, i);
}
//remaining unmarked fragment
echo sub($inputSentence, $lastInsertedEnd);
?>
result->bestOverlay as $fragment) {
?>
= sub($fragment->sourceSegment, 0, $fragment->matchedExampleStart) ?>
= sub($fragment->sourceSegment, $fragment->matchedExampleStart, $fragment->matchedExampleEnd) ?>
= sub($fragment->sourceSegment, $fragment->matchedExampleEnd)?>
|
targetFragments as $targetFragment) {
?>
= sub($fragment->targetSegment, $currStart, $targetFragment[0]); ?>
= sub($fragment->targetSegment, $targetFragment[0], $targetFragment[1]); ?>
targetSegment, $currStart);
?>
|