2017-02-21 09:31:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$url = 'http://@concordia_host@:@concordia_port@';
|
|
|
|
$data = array("operation" => "concordiaSearch","tmId" => intval($_GET["tmId"]),"pattern" => $_GET["pattern"]);
|
|
|
|
|
|
|
|
// 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);
|
2017-02-21 11:57:52 +01:00
|
|
|
$response = file_get_contents($url, false, $context);
|
2017-02-21 09:31:48 +01:00
|
|
|
|
2017-02-21 11:57:52 +01:00
|
|
|
$data = json_decode($response);
|
2017-02-21 09:31:48 +01:00
|
|
|
?>
|
2017-02-21 11:51:47 +01:00
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script src="js/jquery-1.11.3.min.js"></script>
|
|
|
|
<script src="js/cat.js"></script>
|
|
|
|
<link rel="stylesheet" href="css/iatagger.css" />
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
</head>
|
2017-02-21 11:57:52 +01:00
|
|
|
<body>
|
2017-02-21 12:00:15 +01:00
|
|
|
<div id="header">
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<div id="result">
|
2017-02-21 12:01:17 +01:00
|
|
|
<pre><?php print_r($data);?></pre>
|
2017-02-21 12:07:01 +01:00
|
|
|
<div id="result-score">Concordia score: <b><?= round($data->result->bestOverlayScore*100) ?>%</b></div>
|
2017-02-21 11:57:52 +01:00
|
|
|
<?php
|
2017-02-21 12:43:05 +01:00
|
|
|
|
2017-02-21 12:39:22 +01:00
|
|
|
$inputSentence = $_GET["pattern"];
|
|
|
|
$markedSentence = "";
|
|
|
|
$fragments = array();
|
|
|
|
$lastInsertedEnd = 0;
|
2017-02-21 12:44:26 +01:00
|
|
|
for($i=0; $i<count($data->result->bestOverlayScore);$i++) {
|
2017-02-21 12:39:22 +01:00
|
|
|
$fragment = data->result->bestOverlay[i];
|
2017-02-21 12:00:15 +01:00
|
|
|
//previous unmarked fragment
|
2017-02-21 12:39:22 +01:00
|
|
|
$markedSentence += substr($inputSentence,$lastInsertedEnd, $fragment->matchedPatternStart - $lastInsertedEnd);
|
2017-02-21 11:57:52 +01:00
|
|
|
|
2017-02-21 12:00:15 +01:00
|
|
|
//the marked fragment
|
2017-02-21 12:39:22 +01:00
|
|
|
$markedSentence += '<span onclick="displayDetails(this, '+i+')" class="matchedFragment">'+substr($inputSentence,$fragment->matchedPatternStart, $fragment->matchedPatternEnd - $fragment->matchedPatternStart)+'</span>';
|
2017-02-21 11:57:52 +01:00
|
|
|
|
2017-02-21 12:39:22 +01:00
|
|
|
$lastInsertedEnd = $fragment->matchedPatternEnd;
|
2017-02-21 11:57:52 +01:00
|
|
|
|
2017-02-21 12:39:22 +01:00
|
|
|
//fragments += renderFragment(fragment, i);
|
2017-02-21 11:57:52 +01:00
|
|
|
|
2017-02-21 12:39:22 +01:00
|
|
|
}
|
2017-02-21 12:00:15 +01:00
|
|
|
//remaining unmarked fragment
|
2017-02-21 12:39:22 +01:00
|
|
|
$markedSentence += substr($inputSentence, $lastInsertedEnd);
|
2017-02-21 12:43:05 +01:00
|
|
|
|
2017-02-21 12:00:15 +01:00
|
|
|
?>
|
2017-02-21 12:39:22 +01:00
|
|
|
<div id="result-sentence" onMouseUp="phraseSearch(this)"><?=$markedSentence ?></div>
|
|
|
|
<br/><br/><br/>
|
2017-02-21 12:00:15 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-02-21 11:51:47 +01:00
|
|
|
</body>
|
|
|
|
</html>
|