blob: 5ac5fe964ad10d9b0d1c2a1607eb696b5e280072 (
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
33
34
35
36
37
38
39
|
#include "search/hotels_classifier.hpp"
#include "search/result.hpp"
namespace search
{
// static
bool HotelsClassifier::IsHotelResults(Results const & results)
{
HotelsClassifier classifier;
for (auto const & r : results)
classifier.Add(r);
return classifier.IsHotelResults();
}
void HotelsClassifier::Add(Result const & result)
{
if (result.m_metadata.m_isHotel)
++m_numHotels;
++m_numResults;
}
void HotelsClassifier::Clear()
{
m_numHotels = 0;
m_numResults = 0;
}
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
|