18 ResultCombination::ResultCombination()
19 : _travelQuery (
""), _bestMatchingResultHolder (NULL) {
24 ResultCombination::ResultCombination (
const ResultCombination&)
25 : _travelQuery (
""), _bestMatchingResultHolder (NULL) {
30 ResultCombination::ResultCombination (
const TravelQuery_T& iQueryString)
31 : _travelQuery (iQueryString), _bestMatchingResultHolder (NULL) {
36 ResultCombination::~ResultCombination() {
37 _bestMatchingResultHolder = NULL;
41 void ResultCombination::init () {
42 _resultHolderList.clear();
46 const ResultHolder& ResultCombination::getBestMatchingResultHolder()
const {
47 if (_bestMatchingResultHolder == NULL) {
48 std::ostringstream oStr;
49 oStr <<
"There is no best matching ResultHolder object for the given "
50 <<
"query string: '" << _travelQuery <<
"'";
54 assert (_bestMatchingResultHolder != NULL);
55 return *_bestMatchingResultHolder;
59 const Percentage_T& ResultCombination::getBestMatchingWeight()
const {
60 const ResultHolder& lResultHolder = getBestMatchingResultHolder();
66 StringSet ResultCombination::getCorrectedStringSet()
const {
67 const ResultHolder& lResultHolder = getBestMatchingResultHolder();
73 std::string ResultCombination::describeShortKey()
const {
74 std::ostringstream oStr;
80 std::string ResultCombination::describeKey()
const {
81 return describeShortKey();
85 std::string ResultCombination::toString()
const {
86 std::ostringstream oStr;
87 oStr << describeShortKey() << std::endl;
89 for (ResultHolderList_T::const_iterator itResultHolder =
90 _resultHolderList.begin();
91 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
93 assert (lResultHolder_ptr != NULL);
95 oStr <<
" ==> " << std::endl << lResultHolder_ptr->
toString();
102 void ResultCombination::toStream (std::ostream& ioOut)
const {
107 void ResultCombination::fromStream (std::istream& ioIn) {
111 void ResultCombination::displayXapianPercentages()
const {
113 for (ResultHolderList_T::const_iterator itResultHolder =
114 _resultHolderList.begin();
115 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
117 assert (lResultHolder_ptr != NULL);
125 void ResultCombination::calculateEnvelopeWeights()
const {
127 for (ResultHolderList_T::const_iterator itResultHolder =
128 _resultHolderList.begin();
129 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
131 assert (lResultHolder_ptr != NULL);
139 void ResultCombination::calculateCodeMatches()
const {
141 for (ResultHolderList_T::const_iterator itResultHolder =
142 _resultHolderList.begin();
143 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
145 assert (lResultHolder_ptr != NULL);
153 void ResultCombination::calculatePageRanks()
const {
155 for (ResultHolderList_T::const_iterator itResultHolder =
156 _resultHolderList.begin();
157 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
159 assert (lResultHolder_ptr != NULL);
167 void ResultCombination::calculateHeuristicWeights()
const {
169 for (ResultHolderList_T::const_iterator itResultHolder =
170 _resultHolderList.begin();
171 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
173 assert (lResultHolder_ptr != NULL);
181 void ResultCombination::calculateCombinedWeights()
const {
183 for (ResultHolderList_T::const_iterator itResultHolder =
184 _resultHolderList.begin();
185 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
187 assert (lResultHolder_ptr != NULL);
195 void ResultCombination::calculateAllWeights() {
199 displayXapianPercentages();
204 calculateEnvelopeWeights();
210 calculateCodeMatches();
215 calculatePageRanks();
220 calculateHeuristicWeights();
225 calculateCombinedWeights();
229 bool ResultCombination::chooseBestMatchingResultHolder() {
234 for (ResultHolderList_T::const_iterator itResultHolder =
235 _resultHolderList.begin();
236 itResultHolder != _resultHolderList.end(); ++itResultHolder) {
238 assert (lResultHolder_ptr != NULL);
246 if (lMatchingPercentage > lMaxMatchingPercentage) {
247 lMaxMatchingPercentage = lMatchingPercentage;
248 _bestMatchingResultHolder = lResultHolder_ptr;
253 if (_bestMatchingResultHolder != NULL) {
255 <<
"' string has a weight of "
256 << lMaxMatchingPercentage
257 <<
"%. It is the following string partition: "
258 << _bestMatchingResultHolder->describeKey());
262 << describeKey() <<
"' string");
266 const bool doesBestMatchingResultHolderExist =
267 (_bestMatchingResultHolder != NULL);
268 return doesBestMatchingResultHolderExist;
#define OPENTREP_LOG_ERROR(iToBeLogged)
#define OPENTREP_LOG_DEBUG(iToBeLogged)
Class wrapping functions on a list of Result objects.
StringSet getCorrectedStringSet() const
void calculateEnvelopeWeights() const
void calculateCombinedWeights()
void calculateCodeMatches() const
void calculatePageRanks() const
void calculateHeuristicWeights() const
const Percentage_T & getCombinedWeight() const
std::string toString() const
void displayXapianPercentages() const
std::string toString(const TokenList_T &iTokenList)
Class holding a set of strings, e.g., {"rio", "de", "janeiro"}.