diff --git a/.gitignore b/.gitignore index f46bc60..bd6ebab 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ db/pgbouncer.pid db/pgbouncer.ini upstart/concordia-server.conf upstart/pgbouncer.conf +cat/host.cfg diff --git a/cat/README b/cat/README new file mode 100644 index 0000000..93bae65 --- /dev/null +++ b/cat/README @@ -0,0 +1,5 @@ +1. Prepare host.cfg file with the address and port number of Concordia. See host.cfg_example. WARNING there should not be any empty lines in the .cfg files. +2. Prepare version file for each tm in Concordia in teh "versions: directory. +3. Clean a directory on your webserver (that supports PHP). +4. sudo ./publish.py PATH_ON_SERVER. + diff --git a/cat/concordia_gate.php b/cat/concordia_gate.php_pattern similarity index 60% rename from cat/concordia_gate.php rename to cat/concordia_gate.php_pattern index b950507..df52e6b 100644 --- a/cat/concordia_gate.php +++ b/cat/concordia_gate.php_pattern @@ -1,7 +1,11 @@ $_POST["operation"],"tmId" => intval($_POST["tmId"]),"pattern" => $_POST["pattern"]); +$url = 'http://@concordia_host@:@concordia_port@'; +$intervalsArray = array(); +foreach ($_POST["intervals"] as $interval) { + array_push($intervalsArray, [intval($interval[0]), intval($interval[1])]); +} +$data = array("operation" => $_POST["operation"],"tmId" => intval($_POST["tmId"]),"pattern" => $_POST["pattern"],"intervals" => $intervalsArray); // use key 'http' even if you send the request to https://... $options = array( diff --git a/cat/css/iatagger.css b/cat/css/iatagger.css index 7043eae..a468bd3 100644 --- a/cat/css/iatagger.css +++ b/cat/css/iatagger.css @@ -133,6 +133,12 @@ cursor:text; } +#result-sentence.phrase-mode .matchedFragmentSelected { + background-color:#e5e5ff; + border-color:#e5e5ff; + cursor:text; +} + .matchedFragment { background-color:#99CCFF; border-style: solid; diff --git a/cat/host.cfg_example b/cat/host.cfg_example new file mode 100644 index 0000000..a9cf9de --- /dev/null +++ b/cat/host.cfg_example @@ -0,0 +1,3 @@ +concordia_host@#@concordia.vm.wmi.amu.edu.pl +concordia_port@#@8800 + diff --git a/cat/index.html_pattern b/cat/index.html_pattern index b14387b..3f11fc8 100644 --- a/cat/index.html_pattern +++ b/cat/index.html_pattern @@ -8,10 +8,11 @@ - - - - - - -
- Banner -


-

- Welcome to Concordia. The system finds the longest matches of the pattern sentence in its translation memory. This translation memory is 200 000 sentences taken from the SETIMES2 Croatian-English corpus (link). Please enter a Croatian sentence in the field below and press Enter (or use the search button). You can test the system on predefined samples, simply use the link "show/hide samples" and apply one of the sample sentences. -

-

- Enjoy your work with the system! -

- - show/hide samples -

-
- -

-
- -

- -



-
- -
-
- - diff --git a/cat/js/cat.js b/cat/js/cat.js index cb6e040..152a8d0 100644 --- a/cat/js/cat.js +++ b/cat/js/cat.js @@ -20,6 +20,26 @@ function searchHandle(tmid) { }); } +function phraseSearchHandle(tmid, intervals) { + var concordiaRequest = { + operation: 'concordiaPhraseSearch', + tmId: tmid, + pattern:$("#search-input").val(), + intervals: intervals + } + + + $.ajax({ + url: '/concordia_gate.php', + type: 'post', + dataType: 'json', + success: function (data) { + $('#result').html(renderResult(data)); + }, + data: concordiaRequest + }); +} + function renderResult(data) { var res = ''; @@ -110,9 +130,18 @@ function showHideSuggestions() { function phraseSearch(caller) { if ($('#result-sentence').hasClass('phrase-mode')) { var phrase = getSelectedTextWithin(caller); - console.log('phrase search for: '+phrase); - console.log(getIndicesOf(phrase, $("#search-input").val(), true)); - var phrases = $('phrase-prompt').data(); + if (phrase.length > 0) { + + var intervalStarts = getIndicesOf(phrase, $("#search-input").val(), true); + var intervals = []; + + for (var i=0;i #include +#include + #include "json_generator.hpp" #include "config.hpp" #include "logger.hpp" @@ -35,6 +37,7 @@ std::string ConcordiaServer::handleRequest(std::string & requestString) { outputString << "Content-type: application/json\r\n\r\n"; try { rapidjson::Document d; + Logger::logString("concordia request string", requestString); bool hasError = d.Parse(requestString.c_str()).HasParseError(); if (hasError) { @@ -99,6 +102,19 @@ std::string ConcordiaServer::handleRequest(std::string & requestString) { int tmId = _getIntParameter(d, TM_ID_PARAM); Logger::logString("concordia search pattern", pattern); _searcherController->concordiaSearch(jsonWriter, pattern, tmId); + } else if (operation == CONCORDIA_PHRASE_SEARCH_OP) { + std::string pattern = _getStringParameter(d, PATTERN_PARAM); + int tmId = _getIntParameter(d, TM_ID_PARAM); + Logger::logString("concordia phrase search pattern", pattern); + std::vector intervals; + const rapidjson::Value & intervalsArray = d[INTERVALS_PARAM]; + for (rapidjson::SizeType i = 0; i < intervalsArray.Size(); i++) { + Logger::logInt("interval size", intervalsArray[i].Size()); + Logger::logInt("search interval start", intervalsArray[i][0].GetInt()); + Logger::logInt("search interval end", intervalsArray[i][1].GetInt()); + } + + //_searcherController->concordiaPhraseSearch(jsonWriter, pattern, tmId); } else if (operation == ADD_TM_OP) { int sourceLangId = _getIntParameter(d, SOURCE_LANG_PARAM); int targetLangId = _getIntParameter(d, TARGET_LANG_PARAM); diff --git a/concordia-server/config.hpp.in b/concordia-server/config.hpp.in index c068781..e96fafd 100644 --- a/concordia-server/config.hpp.in +++ b/concordia-server/config.hpp.in @@ -19,6 +19,7 @@ #define SOURCE_LANG_PARAM "sourceLangId" #define TARGET_LANG_PARAM "targetLangId" #define NAME_PARAM "name" +#define INTERVALS_PARAM "intervals" #define ADD_SENTENCE_OP "addSentence" #define ADD_SENTENCES_OP "addSentences" @@ -26,5 +27,6 @@ #define REFRESH_INDEX_OP "refreshIndex" #define SIMPLE_SEARCH_OP "simpleSearch" #define CONCORDIA_SEARCH_OP "concordiaSearch" +#define CONCORDIA_PHRASE_SEARCH_OP "concordiaPhraseSearch" #define ADD_TM_OP "addTm"