This commit is contained in:
rjawor 2019-05-21 12:00:43 +02:00
parent 217fa0d9c7
commit b94fa3b318

View File

@ -167,11 +167,19 @@ SimpleSearchResult UnitDAO::_getResultFromFragment(
} }
ExampleOccurrence UnitDAO::_getExampleOccurrence(DBconnection & connection, const SubstringOccurrence sOccurrence, const int matchedLength) { ExampleOccurrence UnitDAO::_getExampleOccurrence(DBconnection & connection, const SubstringOccurrence sOccurrence, const int matchedLength) {
Logger::log("_getExampleOccurrence");
std::string query = "SELECT unit.id, unit.source_segment, unit.target_segment, unit.source_tokens[$1::integer], unit.source_tokens[$2::integer], unit.target_tokens, unit.alignments, source.name, source.link FROM unit left join source on unit.source_id = source.external_id where unit.id = $3::integer;"; std::string query = "SELECT unit.id, unit.source_segment, unit.target_segment, unit.source_tokens[$1::integer], unit.source_tokens[$2::integer], unit.target_tokens, unit.alignments, source.name, source.link FROM unit left join source on unit.source_id = source.external_id where unit.id = $3::integer;";
std::vector<QueryParam*> params; std::vector<QueryParam*> params;
params.push_back(new IntParam(2*sOccurrence.getOffset()+1)); int sourceTokenStart = 2*sOccurrence.getOffset()+1;
params.push_back(new IntParam(2*(sOccurrence.getOffset()+matchedLength))); int sourceTokenEnd = 2*(sOccurrence.getOffset()+matchedLength);
params.push_back(new IntParam(sOccurrence.getId())); int sourceId = sOccurrence.getId();
Logger::logInt("sourceTokenStart", sourceTokenStart);
Logger::logInt("sourceTokenEnd", sourceTokenEnd);
Logger::logInt("sourceId", sourceId);
params.push_back(new IntParam(sourceTokenStart));
params.push_back(new IntParam(sourceTokenEnd);
params.push_back(new IntParam(sourceId));
PGresult * result = connection.execute(query, params); PGresult * result = connection.execute(query, params);
ExampleOccurrence occurrence(connection.getIntValue(result,0,0), // example id ExampleOccurrence occurrence(connection.getIntValue(result,0,0), // example id
connection.getIntValue(result,0,3), // matched example start connection.getIntValue(result,0,3), // matched example start