diff options
Diffstat (limited to 'search/hotels_classifier.cpp')
-rw-r--r-- | search/hotels_classifier.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/search/hotels_classifier.cpp b/search/hotels_classifier.cpp new file mode 100644 index 0000000000..4a21d3cb67 --- /dev/null +++ b/search/hotels_classifier.cpp @@ -0,0 +1,28 @@ +#include "search/hotels_classifier.hpp" + +#include "search/result.hpp" + +namespace search +{ +void HotelsClassifier::AddBatch(Results const & results) +{ + if (results.IsEndMarker()) + return; + + for (auto const & result : results) + { + ++m_numResults; + if (result.m_metadata.m_isHotel) + ++m_numHotels; + } +} + +bool HotelsClassifier::IsHotelQuery() const +{ + // Threshold used to activate hotels mode. Probably is too strict, + // but we don't have statistics now. + double const kThreshold = 0.95; + + return m_numResults == 0 ? false : m_numHotels >= kThreshold * m_numResults; +} +} // namespace search |