[search] Moved search quality tests to a separate library.

Also, separated out the binary of the search quality tool.
This commit is contained in:
Maxim Pimenov 2016-03-04 15:26:37 +03:00 committed by Sergey Yershov
parent 618362c66a
commit f11b91d835
11 changed files with 81 additions and 45 deletions

View file

@ -56,7 +56,6 @@ SUBDIRS = 3party base coding geometry editor indexer routing search
SUBDIRS *= skin_generator
}
CONFIG(desktop) {
drape_head.depends = $$SUBDIRS
SUBDIRS *= drape_head
@ -71,6 +70,15 @@ SUBDIRS = 3party base coding geometry editor indexer routing search
SUBDIRS *= benchmark_tool mapshot qt
}
CONFIG(desktop) {
search_quality.subdir = search/search_quality
search_quality.depends = $$SUBDIRS
search_quality_tool.subdir = search/search_quality/search_quality_tool
search_quality_tool.depends = $$SUBDIRS search_quality
SUBDIRS *= search_quality search_quality_tool
}
CONFIG(desktop):!CONFIG(no-tests) {
# Additional desktop-only, tests-only libraries.
platform_tests_support.subdir = platform/platform_tests_support
@ -160,8 +168,8 @@ SUBDIRS = 3party base coding geometry editor indexer routing search
search_integration_tests.depends = $$MapDepLibs search_tests_support generator
SUBDIRS *= search_integration_tests
search_quality_tests.subdir = search/search_quality_tests
search_quality_tests.depends = $$MapDepLibs generator search_tests_support
search_quality_tests.subdir = search/search_quality/search_quality_tests
search_quality_tests.depends = $$MapDepLibs generator search_quality search_tests_support
SUBDIRS *= search_quality_tests
generator_tests.subdir = generator/generator_tests

View file

@ -8,8 +8,6 @@ ROOT_DIR = ..
include($$ROOT_DIR/common.pri)
INCLUDEPATH += $$ROOT_DIR/3party/jansson/src
HEADERS += \
algos.hpp \
approximate_string_match.hpp \
@ -34,7 +32,6 @@ HEADERS += \
result.hpp \
retrieval.hpp \
reverse_geocoder.hpp \
sample.hpp \
search_common.hpp \
search_engine.hpp \
search_index_values.hpp \
@ -81,7 +78,6 @@ SOURCES += \
result.cpp \
retrieval.cpp \
reverse_geocoder.cpp \
sample.cpp \
search_engine.cpp \
search_query.cpp \
search_query_params.cpp \

View file

@ -11,6 +11,11 @@
namespace
{
void FromJSON(json_t * root, string & result)
{
result = string(json_string_value(root));
}
void FromJSONObject(json_t * root, string const & field, string & result)
{
if (!json_is_object(root))
@ -69,24 +74,6 @@ void FromJSONObject(json_t * root, string const & field, m2::RectD & result)
result.setMaxY(maxY);
}
void FromJSONObject(json_t * root, string const & field, vector<string> & result)
{
json_t * arr = json_object_get(root, field.c_str());
if (!arr)
MYTHROW(my::Json::Exception, ("Obligatory field", field, "is absent."));
if (!json_is_array(arr))
MYTHROW(my::Json::Exception, ("The field", field, "must contain a json array."));
size_t const sz = json_array_size(arr);
result.resize(sz);
for (size_t i = 0; i < sz; ++i)
{
json_t * elem = json_array_get(arr, i);
if (!json_is_string(elem))
MYTHROW(my::Json::Exception, ("Wrong type:", field, "must contain an array of strings."));
result[i] = json_string_value(elem);
}
}
void FromJSONObject(json_t * root, string const & field, search::Sample::Result::Relevance & r)
{
string relevance;
@ -99,14 +86,7 @@ void FromJSONObject(json_t * root, string const & field, search::Sample::Result:
r = search::Sample::Result::Relevance::RELEVANCE_IRRELEVANT;
}
void FromJSON(json_t * root, search::Sample::Result & result)
{
FromJSONObject(root, "position", result.m_pos);
FromJSONObject(root, "name", result.m_name);
FromJSONObject(root, "houseNumber", result.m_houseNumber);
FromJSONObject(root, "types", result.m_types);
FromJSONObject(root, "relevancy", result.m_relevance);
}
void FromJSON(json_t * root, search::Sample::Result & result);
template <typename T>
void FromJSONObject(json_t * root, string const & field, vector<T> & result)
@ -122,6 +102,15 @@ void FromJSONObject(json_t * root, string const & field, vector<T> & result)
FromJSON(json_array_get(arr, i), result[i]);
}
void FromJSON(json_t * root, search::Sample::Result & result)
{
FromJSONObject(root, "position", result.m_pos);
FromJSONObject(root, "name", result.m_name);
FromJSONObject(root, "houseNumber", result.m_houseNumber);
FromJSONObject(root, "types", result.m_types);
FromJSONObject(root, "relevancy", result.m_relevance);
}
bool LessRect(m2::RectD const & lhs, m2::RectD const & rhs)
{
if (lhs.minX() != rhs.minX())

View file

@ -0,0 +1,17 @@
# Search quality library.
TARGET = search_quality
TEMPLATE = lib
CONFIG += staticlib warn_on
ROOT_DIR = ../..
include($$ROOT_DIR/common.pri)
INCLUDEPATH += $$ROOT_DIR/3party/jansson/src
HEADERS += \
sample.hpp \
SOURCES += \
sample.cpp \

View file

@ -1,6 +1,6 @@
#include "testing/testing.hpp"
#include "search/sample.hpp"
#include "search/search_quality/sample.hpp"
#include "base/logging.hpp"

View file

@ -0,0 +1,26 @@
# Search quality library tests.
TARGET = search_quality_tests
CONFIG += console warn_on
CONFIG -= app_bundle
TEMPLATE = app
ROOT_DIR = ../../..
# todo(@m) revise
DEPENDENCIES = map drape_frontend routing search_tests_support search search_quality storage indexer drape platform geometry coding base \
freetype expat fribidi tomcrypt gflags jansson protobuf osrm stats_client minizip succinct \
opening_hours
include($$ROOT_DIR/common.pri)
INCLUDEPATH += $$ROOT_DIR/3party/jansson/src
QT *= core
macx-*: LIBS *= "-framework IOKit"
SOURCES += \
../../../testing/testingmain.cpp \
sample_test.cpp \
HEADERS += \

View file

@ -52,7 +52,8 @@ using namespace search::tests_support;
DEFINE_string(data_path, "", "Path to data directory (resources dir)");
DEFINE_string(locale, "en", "Locale of all the search queries");
DEFINE_int32(num_threads, 1, "Number of search engine threads");
DEFINE_string(mwm_list_path, "", "Path to a file containing the names of available mwms, one per line");
DEFINE_string(mwm_list_path, "",
"Path to a file containing the names of available mwms, one per line");
DEFINE_string(mwm_path, "", "Path to mwm files (writable dir)");
DEFINE_string(queries_path, "", "Path to the file with queries");
DEFINE_int32(top, 1, "Number of top results to show for every query");
@ -445,7 +446,8 @@ int main(int argc, char * argv[])
requests[i]->Wait();
auto rt = duration_cast<milliseconds>(requests[i]->ResponseTime()).count();
responseTimes[i] = static_cast<double>(rt) / 1000;
PrintTopResults(MakePrefixFree(queries[i]), requests[i]->Results(), FLAGS_top, responseTimes[i]);
PrintTopResults(MakePrefixFree(queries[i]), requests[i]->Results(), FLAGS_top,
responseTimes[i]);
}
double averageTime;

View file

@ -1,13 +1,13 @@
# Search quality tests.
# Search quality tool.
TARGET = search_quality_tests
TARGET = search_quality_tool
CONFIG += console warn_on
CONFIG -= app_bundle
TEMPLATE = app
ROOT_DIR = ../..
ROOT_DIR = ../../..
# todo(@m) revise
DEPENDENCIES = map drape_frontend routing search_tests_support search storage indexer drape \
DEPENDENCIES = map drape_frontend routing search_tests_support search search_quality storage indexer drape \
platform editor geometry coding base freetype expat fribidi tomcrypt gflags \
jansson protobuf osrm stats_client minizip succinct \
opening_hours pugixml
@ -16,7 +16,6 @@ include($$ROOT_DIR/common.pri)
INCLUDEPATH *= $$ROOT_DIR/3party/gflags/src
# needed for Platform::WorkingDir() and unicode combining
QT *= core network opengl
@ -24,7 +23,7 @@ macx-* {
LIBS *= "-framework IOKit" "-framework SystemConfiguration"
}
SOURCES += \
search_quality_tests.cpp \
HEADERS += \
SOURCES += \
search_quality_tool.cpp \

View file

@ -29,7 +29,6 @@ SOURCES += \
locality_scorer_test.cpp \
query_saver_tests.cpp \
ranking_tests.cpp \
sample_test.cpp \
string_intersection_test.cpp \
string_match_test.cpp \