From 2946cce274ee470f465f90bf526e40f2c2bb3c13 Mon Sep 17 00:00:00 2001 From: rjawor Date: Tue, 10 Oct 2017 17:27:45 +0200 Subject: [PATCH] changed format for lexicon search result --- concordia-server/json_generator.cpp | 16 ++++++++++++++++ concordia-server/json_generator.hpp | 4 ++++ concordia-server/searcher_controller.cpp | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/concordia-server/json_generator.cpp b/concordia-server/json_generator.cpp index 475756c..7091704 100644 --- a/concordia-server/json_generator.cpp +++ b/concordia-server/json_generator.cpp @@ -59,3 +59,19 @@ void JsonGenerator::writeSimpleSearchResult(rapidjson::Writer & 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 +} diff --git a/concordia-server/json_generator.hpp b/concordia-server/json_generator.hpp index 9fd7319..4f91481 100644 --- a/concordia-server/json_generator.hpp +++ b/concordia-server/json_generator.hpp @@ -22,6 +22,10 @@ public: static void writeSimpleSearchResult(rapidjson::Writer & jsonWriter, const SimpleSearchResult & result); + static void writeLexiconSearchResult(rapidjson::Writer & jsonWriter, + const SimpleSearchResult & result); + + private: }; diff --git a/concordia-server/searcher_controller.cpp b/concordia-server/searcher_controller.cpp index 99268da..13dace8 100644 --- a/concordia-server/searcher_controller.cpp +++ b/concordia-server/searcher_controller.cpp @@ -52,7 +52,7 @@ void SearcherController::lexiconSearch(rapidjson::Writer