From 90bf3fb2e8e608abdeea13c57bebb4320c7e545f Mon Sep 17 00:00:00 2001 From: Yury Melnichek Date: Thu, 26 May 2011 03:48:39 +0200 Subject: [PATCH] Remove obsolete search_processor.?pp --- search/search.pro | 2 - search/search_processor.cpp | 78 ------------------------------------- search/search_processor.hpp | 56 -------------------------- 3 files changed, 136 deletions(-) delete mode 100644 search/search_processor.cpp delete mode 100644 search/search_processor.hpp diff --git a/search/search.pro b/search/search.pro index 0234e07e2e..bf08be26fa 100644 --- a/search/search.pro +++ b/search/search.pro @@ -15,7 +15,6 @@ HEADERS += \ keyword_matcher.hpp \ query.hpp \ result.hpp \ - search_processor.hpp \ string_match.hpp \ SOURCES += \ @@ -24,5 +23,4 @@ SOURCES += \ keyword_matcher.cpp \ query.cpp \ result.cpp \ - search_processor.cpp \ string_match.cpp \ diff --git a/search/search_processor.cpp b/search/search_processor.cpp deleted file mode 100644 index e9d70ff3bc..0000000000 --- a/search/search_processor.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "search_processor.hpp" - -#include "../indexer/feature.hpp" -#include "../indexer/classificator.hpp" - -#include "../base/logging.hpp" - -#include "../std/bind.hpp" - -namespace search -{ - int Score(string const & key, string const & word) - { - size_t const offset = word.find(key); - - if (offset == 0) // best match - from the beginning - { - if (word.size() == key.size()) - return 1000; // full match - else - return 100; // partial match - } - else if (offset == string::npos) // no match - { - return -1; - } - else // match in the middle of the string - return key.size() * 2; // how many symbols matched - } - - Query::Query(string const & line) - { - //utf8_string::Split(line, m_tokens); - } - - bool Query::operator()(char lang, string const & utf8s) - { - vector words; - //utf8_string::Split(utf8s, words); - int score = -1; - for (size_t i = 0; i < m_tokens.size(); ++i) - { - for (size_t j = 0; j < words.size(); ++j) - { - score += Score(m_tokens[i], words[j]); - } - } - if (score > 0) - { - m_queue.push(make_pair(score, Result(utf8s, m_currFeature->GetLimitRect(-1), 0))); - return false; - } - return true; - } - - void Query::Match(FeatureType const & f) - { - m_currFeature = &f; - f.ForEachNameRef(*this); - } - - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - - Processor::Processor(Query & query) - : m_query(query) - { - } - - bool Processor::operator() (FeatureType const & f) const - { - // filter out features without any name - if (f.HasName()) - m_query.Match(f); - return true; - } - -} diff --git a/search/search_processor.hpp b/search/search_processor.hpp deleted file mode 100644 index ef36df3747..0000000000 --- a/search/search_processor.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include "result.hpp" -#include "../geometry/rect2d.hpp" -#include "../std/string.hpp" -#include "../std/vector.hpp" -#include "../std/queue.hpp" - -class FeatureType; - -namespace search -{ - typedef pair elem_type; - struct QueueComparer - { - // custom comparison for priority_queue - bool operator() (elem_type const & e1, elem_type const & e2) const - { - return e1.first < e2.first; - } - }; - - class Query - { - vector m_tokens; - /// custom comparison, holds found features - priority_queue, QueueComparer> m_queue; - - // @TODO refactor and remove - FeatureType const * m_currFeature; - - public: - Query(string const & line); - - bool operator()(char lang, string const & utf8s); - - void Match(FeatureType const & f); - template void ForEachResultRef(T & f) - { - while (!m_queue.empty()) - { - f(m_queue.top().second); - m_queue.pop(); - } - } - }; - - class Processor - { - /// mutable here because indexer stores const ref to functor - mutable Query & m_query; - - public: - Processor(Query & query); - bool operator() (FeatureType const & f) const; - }; -}