two step search in cat

This commit is contained in:
rjawor 2019-01-17 12:20:36 +01:00
parent 0c2e123d42
commit 329421b0c1
13 changed files with 89 additions and 27 deletions

View File

@ -2,7 +2,7 @@
$url = 'http://@concordia_host@:@concordia_port@';
$intervalsArray = array();
$data = array("operation" => $_POST["operation"],"tmId" => intval($_POST["tmId"]),"pattern" => $_POST["pattern"],"intervals" => $intervalsArray);
$data = array("operation" => $_POST["operation"],"tmId" => intval($_POST["tmId"]),"limit" => intval($_POST["limit"]),"offset" => intval($_POST["offset"]),"pattern" => $_POST["pattern"],"intervals" => $intervalsArray);
// use key 'http' even if you send the request to https://...
$options = array(

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -45,6 +45,10 @@
<div id="result">
</div>
<input type="hidden" id="current-offset" value="0" />
<input type="hidden" id="current-pattern" value="" />
<div id="occurences">
</div>
</div>
</body>
</html>

View File

@ -1,3 +1,69 @@
var pageLimit = 20;
function secondStepSearch(caller) {
var fullSearchRequest = {
operation: 'fullSearch',
tmId: currentTmId,
limit: pageLimit,
offset: $('#current-offset').val(),
pattern:caller.innerHTML
}
$.ajax({
url: '/cat/concordia_gate.php',
type: 'post',
dataType: 'json',
success: function (data) {
presentFullSearchResults(data);
},
data: fullSearchRequest
});
}
function presentFullSearchResults(data) {
var pattern = $('#current-pattern').val();
var offset = parseInt($('#current-offset').val());
var begin = offset+1;
var end = offset + pageLimit;
var totalCount = parseInt(data['result']['totalCount']);
if (end > totalCount) {
end = totalCount;
}
var result = 'Showing results '+begin+' - '+end+' of '+totalCount+'<br>';
for (j=0;j<data['result']['occurences'].length;j++) {
var occurence = data['result']['occurences'][j];
result += '<table class="example"><tr><td>';
// source segment
var sourceSegment = occurence['sourceSegment'];
result += sourceSegment.slice(0, occurence['matchedExampleStart']);
result += '<span class="matchedFragment">';
result += sourceSegment.slice(occurence['matchedExampleStart'], occurence['matchedExampleEnd']);
result += '</span>';
result += sourceSegment.slice(occurence['matchedExampleEnd']);
// target segment
result += '</td></tr><tr><td>';
var targetSegment = occurence['targetSegment'];
var currStart = 0;
for (i=0;i<occurence['targetFragments'].length;i++) {
result += targetSegment.slice(currStart, occurence['targetFragments'][i][0]);
result += '<span class="matchedFragment">';
result += targetSegment.slice(occurence['targetFragments'][i][0], occurence['targetFragments'][i][1]);
result += '</span>';
currStart = occurence['targetFragments'][i][1];
}
result += targetSegment.slice(currStart);
result += '</td></tr></table>';
}
$('#occurences').html(result);
}
function showNewTmOptions() {
showField('tm_name');
hideField('tm_id');
@ -71,6 +137,7 @@ function phraseSearchHandle(tmid, intervals) {
}
function renderResult(data) {
$('#occurences').html('');
var res = '';
var disablePhraseSearch = true;
@ -171,24 +238,6 @@ function displayDetails(caller, number) {
}
}
function secondStepSearch(caller) {
var concordiaRequest = {
operation: 'simpleSearch',
tmId: currentTmId,
pattern:caller.innerHTML
}
$.ajax({
url: '/cat/concordia_gate.php',
type: 'post',
dataType: 'json',
success: function (data) {
console.log(data);
},
data: concordiaRequest
});
}
function searchText(text, tmid) {
$("#search-input").val(text);

View File

@ -27,7 +27,7 @@ if len(os.listdir(root_dir))>0:
shutil.copytree('js', root_dir+'/js')
shutil.copytree('css', root_dir+'/css')
shutil.copytree('images', root_dir+'/images')
shutil.copy('favicon.ico', root_dir+'/favicon.ico')
shutil.copy('favicon.ico', '/var/www/html/favicon.ico')
config = dict()

View File

@ -1,7 +1,7 @@
dir@#@europarl_sample
concordia_host@#@localhost
concordia_port@#@8800
tmid@#@2
tmid@#@1
desc@#@Welcome to the interactive Concordia demo. The system finds the longest matches of the pattern sentence in its translation memory. This translation memory is over 1.5M sentences taken from English-Polish corpus of European Law (Europarl + JRC-Acquis). Please enter an English sentence in the field below and press Enter (or use the search button). This instance of Concordia works best with law sentences, but is very likely to output some results for any English sentence. You can also use predefined samples, simply use the link "show/hide samples" and apply one of the sample sentences. After the search, click on the highlighted fragments to see their context.
enjoy@#@Enjoy your work with the system!
prompt@#@Enter search pattern (English sentence):

View File

@ -0,0 +1 @@
../versions_available/europarl_sample.cfg

View File

@ -1 +0,0 @@
../versions_available/jrc_enes.cfg

View File

@ -1 +0,0 @@
../versions_available/stocznia_plen.cfg

View File

@ -1,13 +1,13 @@
#!/bin/sh
echo "Recreating database schema..."
psql -U concordia -p 6543 -h localhost concordia_server -f concordia_server.sql
PGPASSWORD=concordia psql -U concordia -p 6543 -h localhost concordia_server -f concordia_server.sql
echo "Inserting initial data..."
for initFile in `ls init/*`
do
echo "Init file:" $initFile
psql -U concordia -p 6543 -h localhost concordia_server -f $initFile
PGPASSWORD=concordia psql -U concordia -p 6543 -h localhost concordia_server -f $initFile
done
echo "Concordia server database recreation complete!"

9
startAll.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
cd db
./startPGbouncer.sh
cd ..
mono LemmaGenSockets/LemmaGenSockets/bin/Debug/LemmaGenSockets.exe &
scripts/start.sh

View File

@ -58,6 +58,7 @@ data = {
req = urllib2.Request(address)
req.add_header('Content-Type', 'application/json')
response = json.loads(urllib2.urlopen(req, json.dumps(data)).read())
print(response)
tmId = int(response['newTmId'])
print "Added new tm: %d" % tmId

View File

@ -1,7 +1,7 @@
#!/bin/sh
CORPUS_NAME="jrc_enes"
CORPUS_NAME="europarl_sample"
SRC_LANG_ID=2
TRG_LANG_ID=4
TRG_LANG_ID=1
./addAlignedLemmatizedTM.py $CORPUS_NAME ../mgiza-aligner/corpora/$CORPUS_NAME/src_final.txt $SRC_LANG_ID ../mgiza-aligner/corpora/$CORPUS_NAME/trg_final.txt $TRG_LANG_ID ../mgiza-aligner/corpora/$CORPUS_NAME/aligned_final.txt