removed debug
This commit is contained in:
parent
8be39bd5e6
commit
11bd5e1064
@ -47,7 +47,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);
|
||||
// Logger::logString("concordia request string", requestString);
|
||||
bool hasError = d.Parse(requestString.c_str()).HasParseError();
|
||||
|
||||
if (hasError) {
|
||||
|
@ -46,17 +46,11 @@ void SearcherController::fullSearch(rapidjson::Writer<rapidjson::StringBuffer> &
|
||||
const int tmId,
|
||||
const int limit,
|
||||
const int offset) {
|
||||
Logger::logString("full search for pattern", pattern);
|
||||
|
||||
boost::ptr_map<int,Concordia>::iterator it = _concordiasMap->find(tmId);
|
||||
if (it != _concordiasMap->end()) {
|
||||
Logger::log("Concordia got");
|
||||
TokenizedSentence tokenizedPattern = it->second->tokenize(pattern, false, false);
|
||||
Logger::log("sentence tokenized");
|
||||
pattern = _lemmatizerFacade->lemmatizeIfNeeded(tokenizedPattern.getTokenizedSentence(), tmId);
|
||||
Logger::log("sentence lemmatized");
|
||||
FullSearchResult result = _unitDAO.getFullSearchResult(it->second->fullSearch(pattern, limit, offset, true), tokenizedPattern.getTokens().size());
|
||||
Logger::log("full search result acquired");
|
||||
jsonWriter.StartObject();
|
||||
jsonWriter.String("status");
|
||||
jsonWriter.String("success");
|
||||
|
@ -167,19 +167,15 @@ SimpleSearchResult UnitDAO::_getResultFromFragment(
|
||||
}
|
||||
|
||||
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::vector<QueryParam*> params;
|
||||
int sourceTokenStart = 2*sOccurrence.getOffset()+1;
|
||||
int sourceTokenEnd = 2*(sOccurrence.getOffset()+matchedLength);
|
||||
int sourceId = sOccurrence.getId();
|
||||
Logger::logInt("sourceTokenStart", sourceTokenStart);
|
||||
Logger::logInt("sourceTokenEnd", sourceTokenEnd);
|
||||
Logger::logInt("sourceId", sourceId);
|
||||
int exampleId = sOccurrence.getId();
|
||||
|
||||
params.push_back(new IntParam(sourceTokenStart));
|
||||
params.push_back(new IntParam(sourceTokenEnd));
|
||||
params.push_back(new IntParam(sourceId));
|
||||
params.push_back(new IntParam(exampleId));
|
||||
PGresult * result = connection.execute(query, params);
|
||||
ExampleOccurrence occurrence(connection.getIntValue(result,0,0), // example id
|
||||
connection.getIntValue(result,0,3), // matched example start
|
||||
@ -188,32 +184,23 @@ ExampleOccurrence UnitDAO::_getExampleOccurrence(DBconnection & connection, cons
|
||||
connection.getStringValue(result,0,2), // target segment
|
||||
connection.getStringValue(result,0,7), // source name
|
||||
connection.getStringValue(result,0,8)); // source link
|
||||
Logger::logInt("occurence got. Example id", occurrence.getId());
|
||||
|
||||
std::string targetTokensRaw = connection.getStringValue(result,0,5);
|
||||
Logger::log("target tokens got");
|
||||
std::string alignmentsRaw = connection.getStringValue(result,0,6);
|
||||
Logger::log("alignments got");
|
||||
|
||||
connection.clearResult(result);
|
||||
BOOST_FOREACH (QueryParam * param, params) {
|
||||
delete param;
|
||||
}
|
||||
Logger::log("params deleted");
|
||||
|
||||
std::vector<int> targetTokens = _getArray(targetTokensRaw);
|
||||
std::vector<std::vector<int> > alignments = _get2DArray(alignmentsRaw);
|
||||
|
||||
Logger::log("arrays got");
|
||||
|
||||
std::set<int> matchedTargetTokens;
|
||||
for(int sourceTokenIndex = sOccurrence.getOffset(); sourceTokenIndex < sOccurrence.getOffset()+matchedLength; sourceTokenIndex++) {
|
||||
BOOST_FOREACH(int & targetTokenIndex, alignments.at(sourceTokenIndex)) {
|
||||
matchedTargetTokens.insert(targetTokenIndex);
|
||||
Logger::logInt("targetTokenIndex", targetTokenIndex);
|
||||
}
|
||||
}
|
||||
Logger::log("matched target tokens computed");
|
||||
|
||||
int prevPos = -2;
|
||||
int currStart = -1;
|
||||
@ -237,15 +224,11 @@ ExampleOccurrence UnitDAO::_getExampleOccurrence(DBconnection & connection, cons
|
||||
prevPos = targetPos;
|
||||
}
|
||||
|
||||
Logger::log("matched target tokens added");
|
||||
|
||||
// check if there are remaining fragments
|
||||
if (currStart >= 0) {
|
||||
occurrence.addMatchedTargetFragment(std::pair<int,int>(currStart,currEnd));
|
||||
}
|
||||
|
||||
Logger::log("getFullSearchResult done");
|
||||
|
||||
return occurrence;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user