truncated concordia response

This commit is contained in:
rjawor 2018-08-29 15:00:48 +02:00
parent 44905f3a61
commit b446c15faa
3 changed files with 93 additions and 61 deletions

View File

@ -97,7 +97,8 @@ function renderResult(data) {
markedSentence += htmlEncode(inputSentence.slice(lastInsertedEnd, fragment['matchedPatternStart']));
//the marked fragment
markedSentence += '<span onclick="displayDetails(this, '+i+')" class="matchedFragment">'+htmlEncode(inputSentence.slice(fragment['matchedPatternStart'], fragment['matchedPatternEnd']))+'</span>';
var textFragment = htmlEncode(inputSentence.slice(fragment['matchedPatternStart'], fragment['matchedPatternEnd']));
markedSentence += '<span onclick="secondStepSearch(this)" class="matchedFragment">'+textFragment+'</span>';
lastInsertedEnd = fragment['matchedPatternEnd'];
@ -170,6 +171,25 @@ 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);
searchHandle(tmid);

View File

@ -69,7 +69,7 @@ std::vector<SUFFIX_MARKER_TYPE> UnitDAO::addAlignedSentences(
SimpleSearchResult UnitDAO::getSimpleSearchResult(const MatchedPatternFragment & fragment) {
SimpleSearchResult result(fragment.getStart(), fragment.getEnd());
TokenizedSentence ts("");
return _getResultFromFragment(fragment, ts);
return _getResultFromFragment(fragment, ts, true);
}
CompleteConcordiaSearchResult UnitDAO::getConcordiaResult(boost::shared_ptr<ConcordiaSearchResult> rawConcordiaResult) {
@ -91,8 +91,14 @@ CompleteConcordiaSearchResult UnitDAO::getConcordiaResult(boost::shared_ptr<Conc
SimpleSearchResult UnitDAO::_getResultFromFragment(
const MatchedPatternFragment & fragment,
const TokenizedSentence & tokenizedPattern) {
return _getResultFromFragment(fragment, tokenizedPattern, false);
}
SimpleSearchResult UnitDAO::_getResultFromFragment(
const MatchedPatternFragment & fragment,
const TokenizedSentence & tokenizedPattern,
bool getOccurences) {
Logger::log("_getResultFromFragment");
DBconnection connection;
connection.startTransaction();
@ -106,6 +112,7 @@ SimpleSearchResult UnitDAO::_getResultFromFragment(
SimpleSearchResult ssResult(matchedPatternStart, matchedPatternEnd);
if (getOccurences) {
BOOST_FOREACH(SubstringOccurence sOccurence, fragment.getOccurences()) {
std::string query = "SELECT id, source_segment, target_segment, source_tokens[$1::integer], source_tokens[$2::integer] FROM unit WHERE id = $3::integer;";
std::vector<QueryParam*> params;
@ -167,7 +174,7 @@ SimpleSearchResult UnitDAO::_getResultFromFragment(
ssResult.addOccurence(occurence);
}
}
connection.endTransaction();
return ssResult;

View File

@ -52,6 +52,11 @@ private:
const MatchedPatternFragment & fragment,
const TokenizedSentence & tokenizedPattern);
SimpleSearchResult _getResultFromFragment(
const MatchedPatternFragment & fragment,
const TokenizedSentence & tokenizedPattern,
bool getOccurences);
std::vector<int> _getTokenPositions(const TokenizedSentence & ts);
int _addSingleSentence(