Class wrapping a set of Xapian documents having matched a given query string. More...
#include <opentrep/bom/Result.hpp>
Public Member Functions | |
const TravelQuery_T & | getQueryString () const |
const TravelQuery_T & | getCorrectedTravelQuery () const |
bool | hasFullTextMatched () const |
const NbOfErrors_T & | getEditDistance () const |
const NbOfErrors_T & | getAllowableEditDistance () const |
const DocumentList_T & | getDocumentList () const |
const DocumentMap_T & | getDocumentMap () const |
const XapianDocumentPair_T & | getDocumentPair (const Xapian::docid &) const |
const Xapian::Document & | getDocument (const Xapian::docid &) const |
const Xapian::docid & | getBestDocID () const |
const Percentage_T & | getBestCombinedWeight () const |
const RawDataString_T & | getBestDocData () const |
const Xapian::Document & | getBestXapianDocument () const |
void | setQueryString (const TravelQuery_T &iQueryString) |
void | setCorrectedQueryString (const TravelQuery_T &iCorrectedQueryString) |
void | setHasFullTextMatched (const bool iHasFullTextMatched) |
void | setEditDistance (const NbOfErrors_T &iEditDistance) |
void | setAllowableEditDistance (const NbOfErrors_T &iAllowableEditDistance) |
void | addDocument (const Xapian::Document &, const Score_T &) |
void | setBestDocID (const Xapian::docid &iDocID) |
void | setBestCombinedWeight (const Percentage_T &iPercentage) |
void | setBestDocData (const std::string &iDocData) |
void | fillResult (const Xapian::MSet &iMatchingSet) |
void | fillPlace (Place &) const |
std::string | fullTextMatch (const Xapian::Database &, const TravelQuery_T &) |
void | displayXapianPercentages () const |
void | setScoreOnDocMap (const Xapian::docid &, const ScoreType &, const Score_T &) |
void | calculateEnvelopeWeights () |
void | calculateCodeMatches () |
void | calculatePageRanks () |
void | calculateHeuristicWeights () |
void | calculateCombinedWeights () |
void | toStream (std::ostream &ioOut) const |
void | fromStream (std::istream &ioIn) |
std::string | toString () const |
std::string | describeKey () const |
std::string | describeShortKey () const |
Static Public Member Functions | |
static Location | retrieveLocation (const Xapian::Document &) |
static Location | retrieveLocation (const RawDataString_T &) |
static LocationKey | getPrimaryKey (const Xapian::Document &) |
static Score_T | getEnvelopeID (const Xapian::Document &) |
static PageRank_T | getPageRank (const Xapian::Document &) |
Friends | |
class | FacResultHolder |
class | FacResult |
Class wrapping a set of Xapian documents having matched a given query string.
Definition at line 48 of file Result.hpp.
|
inline |
Get the query string.
Definition at line 56 of file Result.hpp.
|
inline |
Get the corrected query string. When empty, it means that no correction was necessary.
Definition at line 64 of file Result.hpp.
Referenced by OPENTREP::ResultHolder::getCorrectedStringSet().
|
inline |
State whether there has been a full-text match.
Definition at line 71 of file Result.hpp.
Referenced by OPENTREP::createPlaces().
|
inline |
Get the edit distance/error, with which the matching has been made.
Definition at line 78 of file Result.hpp.
|
inline |
Get the maximal allowable edit distance/error, with which the matching has been made.
Definition at line 86 of file Result.hpp.
|
inline |
Get the list of documents.
Definition at line 93 of file Result.hpp.
|
inline |
Get the map of documents.
Definition at line 100 of file Result.hpp.
const XapianDocumentPair_T & OPENTREP::Result::getDocumentPair | ( | const Xapian::docid & | iDocID | ) | const |
Get the Xapian document and associated score-board corresponding to the given document ID.
Definition at line 106 of file Result.cpp.
References describeKey(), and OPENTREP_LOG_ERROR.
Referenced by calculateCombinedWeights(), and getDocument().
const Xapian::Document & OPENTREP::Result::getDocument | ( | const Xapian::docid & | iDocID | ) | const |
Get the Xapian document corresponding to the given document ID.
Definition at line 127 of file Result.cpp.
References getDocumentPair().
Referenced by getBestXapianDocument().
|
inline |
Get the Xapian ID of the best matching document.
Definition at line 118 of file Result.hpp.
|
inline |
Get the combined weight, for all the rules (full-text, PageRank, etc)
Definition at line 125 of file Result.hpp.
Referenced by OPENTREP::ResultHolder::calculateCombinedWeights().
|
inline |
Get the details of the best matching document.
Definition at line 132 of file Result.hpp.
Referenced by OPENTREP::createPlaces().
|
inline |
Get the best matching Xapian document.
Definition at line 139 of file Result.hpp.
References getDocument().
|
inline |
Set the query string.
Definition at line 149 of file Result.hpp.
|
inline |
Set the corrected query string.
Definition at line 156 of file Result.hpp.
|
inline |
Set whether there has been a full-text match.
Definition at line 163 of file Result.hpp.
|
inline |
Set the edit distance/error, with which the matching has been made.
Definition at line 170 of file Result.hpp.
|
inline |
Set the maxiaml allowable edit distance/error, with which the matching has been made.
Definition at line 178 of file Result.hpp.
void OPENTREP::Result::addDocument | ( | const Xapian::Document & | iDocument, |
const Score_T & | iScore ) |
Set the latest score for the given type. If no score value has already been stored for that type, create it. void setScore (const ScoreType& iScoreType, const Score_T& iScore) { _scoreBoard.setScore (iScoreType, iScore); } Add a Xapian document to the dedicated (STL) list and (STL) map.
const | Xapian::Document& The Xapian document to be added. |
const | Score_T& The matching percentage. |
Definition at line 141 of file Result.cpp.
References addDocument(), OPENTREP_LOG_DEBUG, and OPENTREP::ScoreType::XAPIAN_PCT.
Referenced by addDocument(), and fillResult().
|
inline |
Set the Xapian ID of the best matching document.
Definition at line 207 of file Result.hpp.
Referenced by calculateCombinedWeights().
|
inline |
Set the best combined weight, for all the rules (full-text, PageRank, etc)
Definition at line 215 of file Result.hpp.
Referenced by calculateCombinedWeights().
|
inline |
Set the details of the best matching document.
Definition at line 222 of file Result.hpp.
Referenced by calculateCombinedWeights().
void OPENTREP::Result::fillResult | ( | const Xapian::MSet & | iMatchingSet | ) |
Extract the best matching Xapian document.
Xapian::MSet& | The Xapian matching set. It can be empty. |
Result& | The holder for the Xapian documents to be stored. |
Definition at line 197 of file Result.cpp.
References addDocument(), and fillResult().
Referenced by fillResult(), and fullTextMatch().
void OPENTREP::Result::fillPlace | ( | Place & | ioPlace | ) | const |
Fill the Place object with the details of the best matching Xapian document.
Place& | The Place object. |
Definition at line 211 of file Result.cpp.
References fillPlace(), OPENTREP::Place::getKey(), OPENTREP_LOG_DEBUG, OPENTREP::Place::setAllowableEditDistance(), OPENTREP::Place::setCorrectedKeywords(), OPENTREP::Place::setDocID(), OPENTREP::Place::setEditDistance(), OPENTREP::Place::setOriginalKeywords(), and OPENTREP::Place::setPercentage().
Referenced by OPENTREP::createPlaces(), and fillPlace().
std::string OPENTREP::Result::fullTextMatch | ( | const Xapian::Database & | iDatabase, |
const TravelQuery_T & | iQueryString ) |
For all the elements (strings) of the travel query (string set), perform a Xapian-based full-text match. That Xapian-based full-text match gives (potentially) a full set of matches, some with the highest matching percentage and some with a lower percentage.
const | Xapian::Database& The Xapian index/database. |
const | TravelQuery_T& The query string. |
Definition at line 521 of file Result.cpp.
References fillResult(), fullTextMatch(), OPENTREP_LOG_DEBUG, OPENTREP_LOG_ERROR, OPENTREP::Filter::shouldKeep(), and toString().
Referenced by fullTextMatch(), and OPENTREP::searchString().
|
static |
Parse the raw data, as stored by the given Xapian document, and holding all the details of a POR (point of reference).
const | Xapian::Document& The Xapian document. |
Definition at line 272 of file Result.cpp.
References retrieveLocation().
Referenced by OPENTREP::createPlaces(), getEnvelopeID(), getPageRank(), OPENTREP::DBManager::getPORByFAACode(), OPENTREP::DBManager::getPORByGeonameID(), OPENTREP::DBManager::getPORByIATACode(), OPENTREP::DBManager::getPORByICAOCode(), OPENTREP::DBManager::getPORByUICCode(), OPENTREP::DBManager::getPORByUNLOCode(), getPrimaryKey(), retrieveLocation(), and retrieveLocation().
|
static |
Parse the raw data, as stored by a typical Xapian document, and holding all the details of a POR (point of reference).
const | RawDataString_T& The Xapian document data. |
Definition at line 258 of file Result.cpp.
References OPENTREP::PORStringParser::generateLocation(), and retrieveLocation().
|
static |
Extract the primary key from the data of the given Xapian document.
The primary key is made of the IATA and ICAO codes, as well as of the Geonames ID. The retrieveLocation() is used to parse the Xapian document raw data.
Xapian::Document& | The Xapian document. |
Definition at line 284 of file Result.cpp.
References OPENTREP::Location::getKey(), getPrimaryKey(), and retrieveLocation().
Referenced by calculateCodeMatches(), calculateCombinedWeights(), calculateEnvelopeWeights(), calculatePageRanks(), displayXapianPercentages(), and getPrimaryKey().
|
static |
Extract the Envelope ID from the data of the given Xapian document.
The retrieveLocation() is used to parse the Xapian document raw data.
Xapian::Document& | The Xapian document. |
Definition at line 295 of file Result.cpp.
References OPENTREP::Location::getEnvelopeID(), getEnvelopeID(), and retrieveLocation().
Referenced by calculateEnvelopeWeights(), and getEnvelopeID().
|
static |
Extract the PageRank from the data of the given Xapian document.
The retrieveLocation() is used to parse the Xapian document raw data.
Xapian::Document& | The Xapian document. |
Definition at line 309 of file Result.cpp.
References OPENTREP::Location::getPageRank(), getPageRank(), and retrieveLocation().
Referenced by calculatePageRanks(), and getPageRank().
void OPENTREP::Result::displayXapianPercentages | ( | ) | const |
Display the Xapian matching percentages for all the matching documents.
That is just a summarising step, for convenience/debug reason. No calculation is done here.
Definition at line 562 of file Result.cpp.
References describeShortKey(), displayXapianPercentages(), getPrimaryKey(), OPENTREP::ScoreBoard::getScore(), OPENTREP_LOG_NOTIFICATION, and OPENTREP::ScoreType::XAPIAN_PCT.
Referenced by displayXapianPercentages(), and OPENTREP::ResultHolder::displayXapianPercentages().
void OPENTREP::Result::setScoreOnDocMap | ( | const Xapian::docid & | iDocID, |
const ScoreType & | iType, | ||
const Score_T & | iScore ) |
Update the ScoreBoard structure, itself associated to the Xapian document corresponding to the given document ID, with the given score.
const | Xapian::docid& Document ID for the Xapian document |
const | ScoreType& Score type |
const | Score_T& Score/weight value |
Definition at line 592 of file Result.cpp.
References describeKey(), OPENTREP_LOG_ERROR, OPENTREP::ScoreBoard::setScore(), and setScoreOnDocMap().
Referenced by calculateCodeMatches(), calculateEnvelopeWeights(), calculatePageRanks(), and setScoreOnDocMap().
void OPENTREP::Result::calculateEnvelopeWeights | ( | ) |
Calculate/set the envelope weights for all the matching documents.
Some documents have a non-null envelope, meaning that they are no longer valid: they were valid for a given period of time in the past, but no longer are. For instance, the corresponding object (POR, airline, etc) may have been closed, removed, replaced.
Definition at line 614 of file Result.cpp.
References calculateEnvelopeWeights(), describeShortKey(), OPENTREP::ScoreType::ENV_ID, getEnvelopeID(), getPrimaryKey(), OPENTREP_LOG_NOTIFICATION, OPENTREP::ScoreBoard::setScore(), and setScoreOnDocMap().
Referenced by calculateEnvelopeWeights(), and OPENTREP::ResultHolder::calculateEnvelopeWeights().
void OPENTREP::Result::calculateCodeMatches | ( | ) |
Calculate/set the IATA/ICAO code matching weights for all the matching documents
Definition at line 653 of file Result.cpp.
References calculateCodeMatches(), OPENTREP::ScoreType::CODE_FULL_MATCH, describeShortKey(), OPENTREP::LocationKey::getIataCode(), getPrimaryKey(), OPENTREP::K_DEFAULT_FULL_CODE_MATCH_PCT, OPENTREP::K_DEFAULT_MODIFIED_MATCHING_PCT, OPENTREP_LOG_NOTIFICATION, OPENTREP::ScoreBoard::setScore(), setScoreOnDocMap(), OPENTREP::WordHolder::tokeniseStringIntoWordList(), and OPENTREP::Filter::trim().
Referenced by calculateCodeMatches(), and OPENTREP::ResultHolder::calculateCodeMatches().
void OPENTREP::Result::calculatePageRanks | ( | ) |
Calculate/set the PageRanks for all the matching documents
Definition at line 746 of file Result.cpp.
References calculatePageRanks(), describeShortKey(), getPageRank(), getPrimaryKey(), OPENTREP_LOG_NOTIFICATION, OPENTREP::ScoreType::PAGE_RANK, OPENTREP::ScoreBoard::setScore(), and setScoreOnDocMap().
Referenced by calculatePageRanks(), and OPENTREP::ResultHolder::calculatePageRanks().
void OPENTREP::Result::calculateHeuristicWeights | ( | ) |
Calculate/set the heuristic weights for all the matching documents
Definition at line 780 of file Result.cpp.
References calculateHeuristicWeights().
Referenced by calculateHeuristicWeights(), and OPENTREP::ResultHolder::calculateHeuristicWeights().
void OPENTREP::Result::calculateCombinedWeights | ( | ) |
Calculate/set the combined weights for all the matching documents. Store the best matching one in the _bestCombinedWeight attribute.
Definition at line 789 of file Result.cpp.
References OPENTREP::ScoreBoard::calculateCombinedWeight(), calculateCombinedWeights(), OPENTREP::ScoreBoard::describe(), describeShortKey(), getDocumentPair(), getPrimaryKey(), OPENTREP_LOG_DEBUG, setBestCombinedWeight(), setBestDocData(), setBestDocID(), OPENTREP::Filter::shouldKeep(), and OPENTREP::WordHolder::tokeniseStringIntoWordList().
Referenced by calculateCombinedWeights(), and OPENTREP::ResultHolder::calculateCombinedWeights().
|
virtual |
Dump a Business Object into an output stream.
ostream& | the output stream. |
Implements OPENTREP::BomAbstract.
Definition at line 97 of file Result.cpp.
References toStream(), and toString().
Referenced by toStream().
|
virtual |
Read a Business Object from an input stream.
istream& | the input stream. |
Implements OPENTREP::BomAbstract.
Definition at line 102 of file Result.cpp.
References fromStream().
Referenced by fromStream().
|
virtual |
Get the serialised version of the Business Object.
Implements OPENTREP::BomAbstract.
Definition at line 65 of file Result.cpp.
References OPENTREP::ScoreBoard::describe(), describeKey(), and toString().
Referenced by toString(), and OPENTREP::ResultHolder::toString().
|
virtual |
Get a string describing the whole key (differentiating two objects at any level).
Implements OPENTREP::BomAbstract.
Definition at line 49 of file Result.cpp.
References describeKey(), and describeShortKey().
Referenced by describeKey(), getDocumentPair(), setScoreOnDocMap(), and toString().
|
virtual |
Get a string describing the short key (differentiating two objects at the same level).
Implements OPENTREP::BomAbstract.
Definition at line 42 of file Result.cpp.
References describeShortKey().
Referenced by calculateCodeMatches(), calculateCombinedWeights(), calculateEnvelopeWeights(), calculatePageRanks(), describeKey(), describeShortKey(), and displayXapianPercentages().
|
friend |
Definition at line 49 of file Result.hpp.
References FacResultHolder.
Referenced by FacResultHolder.
|
friend |