lexicon search
This commit is contained in:
parent
5e1b032ea0
commit
58406809e7
@ -239,6 +239,10 @@ std::string ConcordiaServer::handleRequest(std::string & requestString) {
|
||||
std::string pattern = _getStringParameter(d, PATTERN_PARAM);
|
||||
int tmId = _getIntParameter(d, TM_ID_PARAM);
|
||||
_searcherController->simpleSearch(jsonWriter, pattern, tmId);
|
||||
} else if (operation == LEXICON_SEARCH_OP) {
|
||||
std::string pattern = _getStringParameter(d, PATTERN_PARAM);
|
||||
int tmId = _getIntParameter(d, TM_ID_PARAM);
|
||||
_searcherController->lexiconSearch(jsonWriter, pattern, tmId);
|
||||
} else if (operation == CONCORDIA_SEARCH_OP) {
|
||||
std::string pattern = _getStringParameter(d, PATTERN_PARAM);
|
||||
int tmId = _getIntParameter(d, TM_ID_PARAM);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#define GET_LANGUAGES_OP "getLanguages"
|
||||
#define REFRESH_INDEX_OP "refreshIndex"
|
||||
#define SIMPLE_SEARCH_OP "simpleSearch"
|
||||
#define LEXICON_SEARCH_OP "lexiconSearch"
|
||||
#define CONCORDIA_SEARCH_OP "concordiaSearch"
|
||||
#define CONCORDIA_PHRASE_SEARCH_OP "concordiaPhraseSearch"
|
||||
#define ADD_TM_OP "addTm"
|
||||
|
@ -40,6 +40,25 @@ void SearcherController::simpleSearch(rapidjson::Writer<rapidjson::StringBuffer>
|
||||
}
|
||||
}
|
||||
|
||||
void SearcherController::lexiconSearch(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||
std::string & pattern,
|
||||
const int tmId) {
|
||||
boost::ptr_map<int,Concordia>::iterator it = _concordiasMap->find(tmId);
|
||||
if (it != _concordiasMap->end()) {
|
||||
TokenizedSentence tokenizedPattern = it->second->tokenize(pattern, false, false);
|
||||
pattern = _lemmatizerFacade->lemmatizeIfNeeded(tokenizedPattern.getTokenizedSentence(), tmId);
|
||||
SimpleSearchResult result = _unitDAO.getSimpleSearchResult(it->second->lexiconSearch(pattern, true));
|
||||
jsonWriter.StartObject();
|
||||
jsonWriter.String("status");
|
||||
jsonWriter.String("success");
|
||||
jsonWriter.String("result");
|
||||
JsonGenerator::writeSimpleSearchResult(jsonWriter, result);
|
||||
jsonWriter.EndObject();
|
||||
} else {
|
||||
JsonGenerator::signalError(jsonWriter, "no such tm!");
|
||||
}
|
||||
}
|
||||
|
||||
void SearcherController::concordiaPhraseSearch(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||
std::string & pattern,
|
||||
const std::vector<Interval> & intervals,
|
||||
|
@ -29,6 +29,10 @@ public:
|
||||
std::string & pattern,
|
||||
const int tmId);
|
||||
|
||||
void lexiconSearch(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||
std::string & pattern,
|
||||
const int tmId);
|
||||
|
||||
void concordiaSearch(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||
std::string & pattern,
|
||||
const int tmId);
|
||||
|
Loading…
Reference in New Issue
Block a user