blob: c50c3e9f042eb85e8971cf03ee067b43ef1d1c26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "search/hotels_classifier.hpp"
#include "std/cstdint.hpp"
namespace search
{
// static
bool HotelsClassifier::IsHotelResults(Results const & results)
{
HotelsClassifier classifier;
classifier.Add(results.begin(), results.end());
return classifier.IsHotelResults();
}
void HotelsClassifier::Add(Results::Iter begin, Results::Iter end)
{
for (; begin != end; ++begin)
{
m_numHotels += (*begin).m_metadata.m_isHotel;
++m_numResults;
}
}
bool HotelsClassifier::IsHotelResults() const
{
// Threshold used to activate hotels mode. Probably is too strict,
// but we don't have statistics now.
double const kThreshold = 0.75;
return m_numResults == 0 ? false : m_numHotels >= kThreshold * m_numResults;
}
} // namespace search
|