From 5c2ae86097880f177e62aa83e2276b9ae94c6e66 Mon Sep 17 00:00:00 2001 From: rjawor Date: Tue, 21 Apr 2015 20:44:49 +0200 Subject: [PATCH] output concordia score Former-commit-id: fa7db09fe9319fa844d294ca4e7deb22d1328151 --- concordia-console/concordia-console.cpp | 3 ++- concordia/concordia_search_result.hpp | 4 ++++ concordia/t/test_concordia.cpp | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/concordia-console/concordia-console.cpp b/concordia-console/concordia-console.cpp index a89d86a..5ce5500 100644 --- a/concordia-console/concordia-console.cpp +++ b/concordia-console/concordia-console.cpp @@ -125,7 +125,8 @@ int main(int argc, char** argv) { << " fragments. " << "Search took: " << msdiff.total_milliseconds() << "ms." << std::endl; if (!cli.count("silent")) { - std::cout << "\tBest overlay: " << std::endl; + std::cout << "\tBest overlay (score="<< + result->getBestOverlayScore()<< "): " << std::endl; BOOST_FOREACH(MatchedPatternFragment fragment, result->getBestOverlay()) { std::cout << "\t\tfragment [" << fragment.getStart() diff --git a/concordia/concordia_search_result.hpp b/concordia/concordia_search_result.hpp index 56f76c2..603296d 100644 --- a/concordia/concordia_search_result.hpp +++ b/concordia/concordia_search_result.hpp @@ -39,6 +39,10 @@ public: return _bestOverlay; } + double getBestOverlayScore() const { + return _bestOverlayScore; + } + private: void _checkPossibleOverlays( std::vector currentOverlay, diff --git a/concordia/t/test_concordia.cpp b/concordia/t/test_concordia.cpp index d5b9872..3317cef 100644 --- a/concordia/t/test_concordia.cpp +++ b/concordia/t/test_concordia.cpp @@ -204,9 +204,10 @@ BOOST_AUTO_TEST_CASE( ConcordiaSearch1 ) concordia.refreshSAfromRAM(); boost::shared_ptr searchResult1 = concordia.concordiaSearch("posiada rysia chyba"); - // best overlay: [], [] + // best overlay: [0,2], [2,3], score = BOOST_CHECK_EQUAL(searchResult1->getBestOverlay().size(), 2); + BOOST_CHECK_CLOSE(searchResult1->getBestOverlayScore(), 0.695, 0.1); BOOST_CHECK_EQUAL(searchResult1->getBestOverlay().at(0).getStart(), 0); BOOST_CHECK_EQUAL(searchResult1->getBestOverlay().at(0).getEnd(), 2); BOOST_CHECK_EQUAL(searchResult1->getBestOverlay().at(1).getStart(), 2);