concordia cat

This commit is contained in:
rjawor 2015-08-26 20:13:57 +02:00
parent 14dc4abd56
commit b6895dbe5b
9 changed files with 1069 additions and 0 deletions

24
cat/cat.html Normal file
View File

@ -0,0 +1,24 @@
<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>
<body>
<div id="header">
</div>
<div id="content">
<img src="images/banner.jpg" alt="Banner" />
<br/><br/><br/>
<label for="searchInput">Enter search pattern (sentence):</label>
<input id="searchInput" type="text" value="Każde państwo unii europejskiej dba o dobro obywateli i służbę zdrowia." />
<br/><br/>
<input type="button" value="search" onclick="searchHandle()" />
<br/><br/><br/><br/>
<div id="result">
</div>
</div>
</body>
</html>

952
cat/css/iatagger.css Normal file
View File

@ -0,0 +1,952 @@
@charset "utf-8";
/**
*
* Generic CSS for CakePHP
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.webroot.css
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
* {
margin:0;
padding:0;
}
.fragmentDetails {
border-style: solid;
border-width: 5px;
border-color:#19424F;
border-radius: 10px;
}
.fragmentDetails table {
width:100%;
}
#result-sentence .matchedFragment {
cursor:pointer;
}
.matchedFragment {
background-color:#99CCFF;
border-style: solid;
border-width: 5px;
border-color:#99CCFF;
border-radius: 10px;
padding:3px;
margin:3px;
}
.matchedFragmentSelected {
background-color:#99CCFF;
border-style: solid;
border-width: 5px;
border-color:#19424F;
border-radius: 10px;
padding:3px;
margin:3px;
cursor:pointer;
}
#result-score {
font-style:italic;
margin-bottom:25px;
}
#result-sentence {
text-align:center;
font-size:24px;
white-space:pre;
}
/** General Style Info **/
body {
background: #003d4c;
color: #fff;
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
margin: 0;
}
a {
color: #003d4c;
text-decoration: underline;
font-weight: bold;
}
a:hover {
color: #367889;
text-decoration:none;
}
a img {
border:none;
}
h1, h2, h3, h4 {
font-weight: normal;
margin-bottom:0.5em;
}
h1 {
background:#fff;
color: #003d4c;
font-size: 100%;
}
h2 {
background:#fff;
color: #e32;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-size: 190%;
}
h3 {
color: #2c6877;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-size: 165%;
}
h4 {
color: #993;
font-weight: normal;
}
ul, li {
margin: 0 12px;
}
p {
margin: 0 0 1em 0;
}
/** Layout **/
#container {
text-align: left;
}
#header{
padding: 10px 20px;
}
#header h1 {
line-height:20px;
background: #003d4c url('../img/cake.icon.png') no-repeat left;
color: #fff;
padding: 0px 30px;
}
#header h1 a {
color: #fff;
background: #003d4c;
font-weight: normal;
text-decoration: none;
}
#header h1 a:hover {
color: #fff;
background: #003d4c;
text-decoration: underline;
}
#content{
background: #fff;
clear: both;
color: #333;
padding: 10px 20px 40px 20px;
overflow: auto;
}
#footer {
clear: both;
padding: 6px 10px;
}
#header a, #footer a {
color: #fff;
}
#cake-powered {
float: right;
}
/** containers **/
div.form,
div.index,
div.view {
float:right;
width:76%;
border-left:1px solid #666;
padding:10px 2%;
}
div.actions {
float:left;
width:16%;
padding:10px 1.5%;
}
div.actions h3 {
padding-top:0;
color:#777;
}
/** Tables **/
table {
border-right:0;
clear: both;
color: #333;
margin-bottom: 10px;
}
th {
border:0;
border-bottom:2px solid #555;
text-align: left;
padding:4px;
}
th a {
display: block;
padding: 2px 4px;
text-decoration: none;
}
th a.asc:after {
content: ' ⇣';
}
th a.desc:after {
content: ' ⇡';
}
table tr td {
line-height:200%;
max-width:200px;
padding: 6px;
text-align: left;
vertical-align: top;
border-bottom:1px solid #ddd;
}
table tr:nth-child(even) {
background: #f9f9f9;
}
td.actions {
text-align: center;
white-space: nowrap;
}
table td.actions a {
margin: 0px 6px;
padding:2px 5px;
}
.annotation-column {
width: 80px;
text-align:right;
}
.word-split .word-unsplit-field {
display:none;
}
.word-unsplit .word-split-field {
display:none;
}
.clickable-image {
cursor:pointer;
}
.disabled-image {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
.words-row {
font-weight:bold;
}
div[name=sentence] {
margin-top:20px;
margin-bottom:20px;
}
td.selected {
border: 2px solid #274da5;
}
td.edited {
border: 2px solid red;
}
td.selected .edit-field {
display:none;
}
td.edited .ro-display {
display:none;
}
td.normal-cell .edit-field {
display:none;
}
.choice-available {
border: 1px solid #274da5;
border-radius: 5px;
padding: 2px;
background-color: #FFFFFF;
}
.choice-selected {
border: 2px solid #274da5;
border-radius: 5px;
background-color: #EBF5FF;
padding: 2px;
}
.choice-inactive {
display:none;
}
.bracket-cell {
position:relative;
}
.left-bracket {
background: url('../img/leftBracket.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.right-bracket {
background: url('../img/rightBracket.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
td.normal-cell .choice-available {
display:none;
}
td.selected .choice-available {
display:none;
}
.help-section {
margin-top:20px;
margin-bottom:20px;
}
.suggestion-count-box {
border: 2px solid #FF0000;
border-radius: 5px;
background-color: #FFFFFF;
padding: 2px;
font-weight:bold;
}
.suggestion-box {
position:absolute;
top:-110px;
left:0px;
/*height:110px;*/
border: 2px dashed;
border-color: blue;
border-radius: 10px;
background-color:#CCFFFF;
font-size:75%;
z-index:100;
overflow:hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.suggestion-box-inactive {
display:none;
}
.preloader-inactive {
position:absolute;
display:none;
}
.preloader-active {
position:absolute;
display:inline;
}
/* SQL log */
.cake-sql-log {
background: #fff;
}
.cake-sql-log td {
padding: 4px 8px;
text-align: left;
font-family: Monaco, Consolas, "Courier New", monospaced;
}
.cake-sql-log caption {
color:#fff;
}
#document-list {
float:left;
}
#import-box {
float:right;
}
/** Paging **/
.paging {
background:#fff;
color: #ccc;
margin-top: 1em;
clear:both;
}
.paging .current,
.paging .disabled,
.paging a {
text-decoration: none;
padding: 5px 8px;
display: inline-block
}
.paging > span {
display: inline-block;
border: 1px solid #ccc;
border-left: 0;
}
.paging > span:hover {
background: #efefef;
}
.paging .prev {
border-left: 1px solid #ccc;
-moz-border-radius: 4px 0 0 4px;
-webkit-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;
}
.paging .next {
-moz-border-radius: 0 4px 4px 0;
-webkit-border-radius: 0 4px 4px 0;
border-radius: 0 4px 4px 0;
}
.paging .disabled {
color: #ddd;
}
.paging .disabled:hover {
background: transparent;
}
.paging .current {
background: #efefef;
color: #c73e14;
}
/** Scaffold View **/
dl {
line-height: 2em;
margin: 0em 0em;
width: 60%;
}
dl dd:nth-child(4n+2),
dl dt:nth-child(4n+1) {
background: #f4f4f4;
}
dt {
font-weight: bold;
padding-left: 4px;
vertical-align: top;
width: 10em;
}
dd {
margin-left: 10em;
margin-top: -2em;
vertical-align: top;
}
/** Forms **/
form {
clear: both;
margin-right: 20px;
padding: 0;
width: 95%;
}
fieldset {
border: none;
margin-bottom: 1em;
padding: 16px 10px;
}
fieldset legend {
color: #e32;
font-size: 160%;
font-weight: bold;
}
fieldset fieldset {
margin-top: 0;
padding: 10px 0 0;
}
fieldset fieldset legend {
font-size: 120%;
font-weight: normal;
}
fieldset fieldset div {
clear: left;
margin: 0 20px;
}
form div {
clear: both;
margin-bottom: 1em;
padding: .5em;
vertical-align: text-top;
}
form .input {
color: #444;
}
form .required {
font-weight: bold;
}
form .required label:after {
color: #e32;
content: '*';
display:inline;
}
form div.submit {
border: 0;
clear: both;
margin-top: 10px;
}
label {
display: block;
font-size: 110%;
margin-bottom:3px;
}
input, textarea {
clear: both;
font-size: 140%;
font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif;
padding: 1%;
width:98%;
}
select {
clear: both;
font-size: 120%;
vertical-align: text-bottom;
}
select[multiple=multiple] {
width: 100%;
}
option {
font-size: 120%;
padding: 0 3px;
}
input[type=checkbox] {
clear: left;
float: left;
margin: 0px 6px 7px 2px;
width: auto;
}
input[type=button] {
font-size:100%;
width: auto;
}
div.checkbox label {
display: inline;
}
input[type=radio] {
float:left;
width:auto;
margin: 6px 0;
padding: 0;
line-height: 26px;
}
.radio label {
margin: 0 0 6px 20px;
line-height: 26px;
}
input[type=submit] {
display: inline;
font-size: 110%;
width: auto;
}
form .submit input[type=submit] {
background:#62af56;
background-image: -webkit-gradient(linear, left top, left bottom, from(#76BF6B), to(#3B8230));
background-image: -webkit-linear-gradient(top, #76BF6B, #3B8230);
background-image: -moz-linear-gradient(top, #76BF6B, #3B8230);
border-color: #2d6324;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px;
padding: 8px 10px;
}
form .submit input[type=submit]:hover {
background: #5BA150;
}
/* Form errors */
form .error {
background: #FFDACC;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
font-weight: normal;
}
form .error-message {
-moz-border-radius: none;
-webkit-border-radius: none;
border-radius: none;
border: none;
background: none;
margin: 0;
padding-left: 4px;
padding-right: 0;
}
form .error,
form .error-message {
color: #9E2424;
-webkit-box-shadow: none;
-moz-box-shadow: none;
-ms-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
text-shadow: none;
}
/** Notices and Errors **/
.message {
clear: both;
color: #fff;
font-size: 140%;
font-weight: bold;
margin: 0 0 1em 0;
padding: 5px;
}
.success,
.message,
.cake-error,
.cake-debug,
.notice,
p.error,
.error-message {
background: #ffcc00;
background-repeat: repeat-x;
background-image: -moz-linear-gradient(top, #ffcc00, #E6B800);
background-image: -ms-linear-gradient(top, #ffcc00, #E6B800);
background-image: -webkit-gradient(linear, left top, left bottom, from(#ffcc00), to(#E6B800));
background-image: -webkit-linear-gradient(top, #ffcc00, #E6B800);
background-image: -o-linear-gradient(top, #ffcc00, #E6B800);
background-image: linear-gradient(top, #ffcc00, #E6B800);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border: 1px solid rgba(0, 0, 0, 0.2);
margin-bottom: 18px;
padding: 7px 14px;
color: #404040;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.success,
.message,
.cake-error,
p.error,
.error-message {
clear: both;
color: #fff;
background: #c43c35;
border: 1px solid rgba(0, 0, 0, 0.5);
background-repeat: repeat-x;
background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
background-image: -ms-linear-gradient(top, #ee5f5b, #c43c35);
background-image: -webkit-gradient(linear, left top, left bottom, from(#ee5f5b), to(#c43c35));
background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
background-image: linear-gradient(top, #ee5f5b, #c43c35);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.success {
clear: both;
color: #fff;
border: 1px solid rgba(0, 0, 0, 0.5);
background: #3B8230;
background-repeat: repeat-x;
background-image: -webkit-gradient(linear, left top, left bottom, from(#76BF6B), to(#3B8230));
background-image: -webkit-linear-gradient(top, #76BF6B, #3B8230);
background-image: -moz-linear-gradient(top, #76BF6B, #3B8230);
background-image: -ms-linear-gradient(top, #76BF6B, #3B8230);
background-image: -o-linear-gradient(top, #76BF6B, #3B8230);
background-image: linear-gradient(top, #76BF6B, #3B8230);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
}
p.error {
font-family: Monaco, Consolas, Courier, monospace;
font-size: 120%;
padding: 0.8em;
margin: 1em 0;
}
p.error em {
font-weight: normal;
line-height: 140%;
}
.notice {
color: #000;
display: block;
font-size: 120%;
padding: 0.8em;
margin: 1em 0;
}
.success {
color: #fff;
}
/** Actions **/
.actions ul {
margin: 0;
padding: 0;
}
.actions li {
margin:0 0 0.5em 0;
list-style-type: none;
white-space: nowrap;
padding: 0;
}
.actions ul li a {
font-weight: normal;
display: block;
clear: both;
}
/* Buttons and button links */
input[type=submit],
.actions ul li a,
.actions a {
font-weight:normal;
padding: 4px 8px;
background: #dcdcdc;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#dcdcdc));
background-image: -webkit-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -moz-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -ms-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -o-linear-gradient(top, #fefefe, #dcdcdc);
background-image: linear-gradient(top, #fefefe, #dcdcdc);
color:#333;
border:1px solid #bbb;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
text-decoration: none;
text-shadow: #fff 0px 1px 0px;
min-width: 0;
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
-webkit-user-select: none;
user-select: none;
}
.actions ul li a:hover,
.actions a:hover {
background: #ededed;
border-color: #acacac;
text-decoration: none;
}
input[type=submit]:active,
.actions ul li a:active,
.actions a:active {
background: #eee;
background-image: -webkit-gradient(linear, left top, left bottom, from(#dfdfdf), to(#eee));
background-image: -webkit-linear-gradient(top, #dfdfdf, #eee);
background-image: -moz-linear-gradient(top, #dfdfdf, #eee);
background-image: -ms-linear-gradient(top, #dfdfdf, #eee);
background-image: -o-linear-gradient(top, #dfdfdf, #eee);
background-image: linear-gradient(top, #dfdfdf, #eee);
text-shadow: #eee 0px 1px 0px;
-moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
border-color: #aaa;
text-decoration: none;
}
input[type=text] {
min-width:100px;
}
/** Related **/
.related {
clear: both;
display: block;
}
/** Debugging **/
pre {
color: #000;
background: #f0f0f0;
padding: 15px;
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}
.cake-debug-output {
padding: 0;
position: relative;
}
.cake-debug-output > span {
position: absolute;
top: 5px;
right: 5px;
background: rgba(255, 255, 255, 0.3);
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
padding: 5px 6px;
color: #000;
display: block;
float: left;
-moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.5);
-webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.5);
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.5);
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}
.cake-debug,
.cake-error {
font-size: 16px;
line-height: 20px;
clear: both;
}
.cake-error > a {
text-shadow: none;
}
.cake-error {
white-space: normal;
}
.cake-stack-trace {
background: rgba(255, 255, 255, 0.7);
color: #333;
margin: 10px 0 5px 0;
padding: 10px 10px 0 10px;
font-size: 120%;
line-height: 140%;
overflow: auto;
position: relative;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.cake-stack-trace a {
text-shadow: none;
background: rgba(255, 255, 255, 0.7);
padding: 5px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
margin: 0px 4px 10px 2px;
font-family: sans-serif;
font-size: 14px;
line-height: 14px;
display: inline-block;
text-decoration: none;
-moz-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
}
.cake-code-dump pre {
position: relative;
overflow: auto;
}
.cake-context {
margin-bottom: 10px;
}
.cake-stack-trace pre {
color: #000;
background-color: #F0F0F0;
margin: 0px 0 10px 0;
padding: 1em;
overflow: auto;
text-shadow: none;
}
.cake-stack-trace li {
padding: 10px 5px 0px;
margin: 0 0 4px 0;
font-family: monospace;
border: 1px solid #bbb;
-moz-border-radius: 4px;
-wekbkit-border-radius: 4px;
border-radius: 4px;
background: #dcdcdc;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#dcdcdc));
background-image: -webkit-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -moz-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -ms-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -o-linear-gradient(top, #fefefe, #dcdcdc);
background-image: linear-gradient(top, #fefefe, #dcdcdc);
}
/* excerpt */
.cake-code-dump pre,
.cake-code-dump pre code {
clear: both;
font-size: 12px;
line-height: 15px;
margin: 4px 2px;
padding: 4px;
overflow: auto;
}
.cake-code-dump .code-highlight {
display: block;
background-color: rgba(255, 255, 0, 0.5);
}
.code-coverage-results div.code-line {
padding-left:5px;
display:block;
margin-left:10px;
}
.code-coverage-results div.uncovered span.content {
background:#ecc;
}
.code-coverage-results div.covered span.content {
background:#cec;
}
.code-coverage-results div.ignored span.content {
color:#aaa;
}
.code-coverage-results span.line-num {
color:#666;
display:block;
float:left;
width:20px;
text-align:right;
margin-right:5px;
}
.code-coverage-results span.line-num strong {
color:#666;
}
.code-coverage-results div.start {
border:1px solid #aaa;
border-width:1px 1px 0px 1px;
margin-top:30px;
padding-top:5px;
}
.code-coverage-results div.end {
border:1px solid #aaa;
border-width:0px 1px 1px 1px;
margin-bottom:30px;
padding-bottom:5px;
}
.code-coverage-results div.realstart {
margin-top:0px;
}
.code-coverage-results p.note {
color:#bbb;
padding:5px;
margin:5px 0 10px;
font-size:10px;
}
.code-coverage-results span.result-bad {
color: #a00;
}
.code-coverage-results span.result-ok {
color: #fa0;
}
.code-coverage-results span.result-good {
color: #0a0;
}
/** Elements **/
#url-rewriting-warning {
display:none;
}

3
cat/examples.txt Normal file
View File

@ -0,0 +1,3 @@
Każde państwo unii europejskiej dba o dobro obywateli i służbę zdrowia.
Obywatel chce utrzymać jakość życia na wysokim poziomie.
Gruntowna naprawa silnika samochodu.

BIN
cat/images/banner.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
cat/images/concordia.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

80
cat/js/cat.js Normal file
View File

@ -0,0 +1,80 @@
$(document).ready(function() {
$('#searchInput').bind("enterKey",function(e){
searchHandle();
});
$('#searchInput').keyup(function(e){
if(e.keyCode == 13) {
$(this).trigger("enterKey");
}
});
});
function searchHandle() {
var concordiaRequest = {
operation: 'concordiaSearch',
pattern:$("#searchInput").val()
}
$.ajax({
url: 'http://localhost',
type: 'post',
dataType: 'json',
success: function (data) {
$('#result').html(renderResult(data));
},
data: JSON.stringify(concordiaRequest)
});
}
function renderResult(data) {
var res = '';
var score = data['result']['bestOverlayScore']*100;
res += '<div id="result-score">Concordia score: <b>'+score.toFixed(0)+'%</b></div>';
var inputSentence = $('#searchInput').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']);
//the marked fragment
markedSentence += '<span onclick="displayDetails('+i+')" class="matchedFragment">'+inputSentence.slice(fragment['matchedPatternStart'], fragment['matchedPatternEnd'])+'</span>';
lastInsertedEnd = fragment['matchedPatternEnd'];
fragments += renderFragment(fragment, i);
}
//remaining unmarked fragment
markedSentence += inputSentence.slice(lastInsertedEnd);
res += '<div id="result-sentence">'+markedSentence+'</div>';
res += '<br/><br/><br/>'+fragments;
return res;
}
function renderFragment(fragment, number) {
var result = '<div style="display:none" id="fragment'+number+'" class="fragmentDetails"><table><tr><td>';
var sourceSegment = fragment['sourceSegment'];
result += sourceSegment.slice(0, fragment['matchedExampleStart']);
result += '<span class="matchedFragment">';
result += sourceSegment.slice(fragment['matchedExampleStart'], fragment['matchedExampleEnd']);
result += '</span>';
result += sourceSegment.slice(fragment['matchedExampleEnd']);
result += '</td></tr><tr><td>'+fragment['targetSegment']+'</td></tr></table></div>';
return result;
}
function displayDetails(number) {
$('.fragmentDetails').css('display', 'none');
$('#fragment'+number).css('display', 'block');
}

5
cat/js/jquery-1.11.3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,7 @@ std::string ConcordiaServer::handleRequest(std::string & requestString) {
std::stringstream outputString; std::stringstream outputString;
try { try {
outputString << "Access-Control-Allow-Origin: *\r\n";
outputString << "Content-type: application/json\r\n\r\n"; outputString << "Content-type: application/json\r\n\r\n";
rapidjson::Document d; rapidjson::Document d;
bool hasError = d.Parse(requestString.c_str()).HasParseError(); bool hasError = d.Parse(requestString.c_str()).HasParseError();

View File

@ -23,6 +23,10 @@ void JsonGenerator::writeSearchResult(rapidjson::Writer<rapidjson::StringBuffer>
jsonWriter.StartObject(); jsonWriter.StartObject();
jsonWriter.String("id"); jsonWriter.String("id");
jsonWriter.Int(result.getId()); jsonWriter.Int(result.getId());
jsonWriter.String("matchedPatternStart");
jsonWriter.Int(result.getMatchedPatternStart());
jsonWriter.String("matchedPatternEnd");
jsonWriter.Int(result.getMatchedPatternEnd());
jsonWriter.String("matchedExampleStart"); jsonWriter.String("matchedExampleStart");
jsonWriter.Int(result.getMatchedExampleStart()); jsonWriter.Int(result.getMatchedExampleStart());
jsonWriter.String("matchedExampleEnd"); jsonWriter.String("matchedExampleEnd");