changed format for lexicon search result
This commit is contained in:
parent
58406809e7
commit
2946cce274
@ -59,3 +59,19 @@ void JsonGenerator::writeSimpleSearchResult(rapidjson::Writer<rapidjson::StringB
|
|||||||
|
|
||||||
jsonWriter.EndObject(); //simple search result
|
jsonWriter.EndObject(); //simple search result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonGenerator::writeLexiconSearchResult(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||||
|
const SimpleSearchResult & result) {
|
||||||
|
jsonWriter.StartArray();
|
||||||
|
|
||||||
|
BOOST_FOREACH(ExampleOccurence occurence, result.getOccurences()) {
|
||||||
|
jsonWriter.StartObject();
|
||||||
|
jsonWriter.String("sourceSegment");
|
||||||
|
jsonWriter.String(occurence.getSourceSegment().c_str());
|
||||||
|
jsonWriter.String("targetSegment");
|
||||||
|
jsonWriter.String(occurence.getTargetSegment().c_str());
|
||||||
|
jsonWriter.EndObject(); // occurence
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonWriter.EndArray(); //simple search result
|
||||||
|
}
|
||||||
|
@ -22,6 +22,10 @@ public:
|
|||||||
static void writeSimpleSearchResult(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
static void writeSimpleSearchResult(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||||
const SimpleSearchResult & result);
|
const SimpleSearchResult & result);
|
||||||
|
|
||||||
|
static void writeLexiconSearchResult(rapidjson::Writer<rapidjson::StringBuffer> & jsonWriter,
|
||||||
|
const SimpleSearchResult & result);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ void SearcherController::lexiconSearch(rapidjson::Writer<rapidjson::StringBuffer
|
|||||||
jsonWriter.String("status");
|
jsonWriter.String("status");
|
||||||
jsonWriter.String("success");
|
jsonWriter.String("success");
|
||||||
jsonWriter.String("result");
|
jsonWriter.String("result");
|
||||||
JsonGenerator::writeSimpleSearchResult(jsonWriter, result);
|
JsonGenerator::writeLexiconSearchResult(jsonWriter, result);
|
||||||
jsonWriter.EndObject();
|
jsonWriter.EndObject();
|
||||||
} else {
|
} else {
|
||||||
JsonGenerator::signalError(jsonWriter, "no such tm!");
|
JsonGenerator::signalError(jsonWriter, "no such tm!");
|
||||||
|
Loading…
Reference in New Issue
Block a user