concordia-server/cat/concordia_search.php_pattern

73 lines
2.8 KiB
Plaintext
Raw Normal View History

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 11:57:52 +01:00
<?php
2017-02-21 12:00:15 +01:00
if (!empty($data['result']['bestOverlayScore'])) {
$score = $data['result']['bestOverlayScore']*100;
?>
<div id="result-score">Concordia score: <b>'+<?= $score ?>%</b></div>
<?php
}
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
/*
res += '<div id="phrase-selection">Phrase search mode:&nbsp;<img id="phrase-off-icon" src="../images/switchOff.png" alt="enter phrase search mode" onclick="togglePhraseSearchMode()" title="search for phrases"/><img class="hidden" id="phrase-on-icon" src="../images/switchOn.png" alt="cancel phrase search" onclick="togglePhraseSearchMode()" title="cancel phrase search"/><span id="phrase-prompt" class="hidden">Select continuous phrase: </span></div>';
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
var inputSentence = $('#search-input').val();
var markedSentence = '';
var fragments = '';
lastInsertedEnd = 0;
for(var i = 0; i < data['result']['bestOverlay'].length; i++) {
var fragment = data['result']['bestOverlay'][i];
//previous unmarked fragment
markedSentence += inputSentence.slice(lastInsertedEnd, fragment['matchedPatternStart']);
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
//the marked fragment
markedSentence += '<span onclick="displayDetails(this, '+i+')" class="matchedFragment">'+inputSentence.slice(fragment['matchedPatternStart'], fragment['matchedPatternEnd'])+'</span>';
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
lastInsertedEnd = fragment['matchedPatternEnd'];
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
fragments += renderFragment(fragment, i);
}
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
//remaining unmarked fragment
markedSentence += inputSentence.slice(lastInsertedEnd);
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
res += '<div id="result-sentence" onMouseUp="phraseSearch(this)">'+markedSentence+'</div>';
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
res += '<br/><br/><br/>'+fragments;
*/
2017-02-21 11:57:52 +01:00
2017-02-21 12:00:15 +01:00
?>
</div>
</div>
2017-02-21 11:51:47 +01:00
</body>
</html>