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 107 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 128 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 OPENTREP::ScoreType::XAPIAN_PCT.
Referenced by 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 191 of file Result.cpp.
References addDocument().
Referenced by 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 205 of file Result.cpp.
References 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().
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 515 of file Result.cpp.
References fillResult(), OPENTREP_LOG_DEBUG, OPENTREP_LOG_ERROR, OPENTREP::Filter::shouldKeep(), and toString().
Referenced by 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 266 of file Result.cpp.
Referenced by OPENTREP::createPlaces(), getEnvelopeID(), getPageRank(), and getPrimaryKey().
|
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 252 of file Result.cpp.
References OPENTREP::PORStringParser::generateLocation().
|
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 278 of file Result.cpp.
References OPENTREP::Location::getKey(), and retrieveLocation().
Referenced by calculateCodeMatches(), calculateCombinedWeights(), calculateEnvelopeWeights(), calculatePageRanks(), and displayXapianPercentages().
|
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 289 of file Result.cpp.
References OPENTREP::Location::getEnvelopeID(), and retrieveLocation().
Referenced by calculateEnvelopeWeights().
|
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 303 of file Result.cpp.
References OPENTREP::Location::getPageRank(), and retrieveLocation().
Referenced by calculatePageRanks().
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 556 of file Result.cpp.
References describeShortKey(), getPrimaryKey(), OPENTREP::ScoreBoard::getScore(), OPENTREP_LOG_NOTIFICATION, and OPENTREP::ScoreType::XAPIAN_PCT.
Referenced by 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 586 of file Result.cpp.
References describeKey(), OPENTREP_LOG_ERROR, and OPENTREP::ScoreBoard::setScore().
Referenced by calculateCodeMatches(), calculateEnvelopeWeights(), and calculatePageRanks().
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 608 of file Result.cpp.
References describeShortKey(), OPENTREP::ScoreType::ENV_ID, getEnvelopeID(), getPrimaryKey(), OPENTREP_LOG_NOTIFICATION, OPENTREP::ScoreBoard::setScore(), and setScoreOnDocMap().
Referenced by OPENTREP::ResultHolder::calculateEnvelopeWeights().
void OPENTREP::Result::calculateCodeMatches | ( | ) |
Calculate/set the IATA/ICAO code matching weights for all the matching documents
Definition at line 647 of file Result.cpp.
References 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 OPENTREP::ResultHolder::calculateCodeMatches().
void OPENTREP::Result::calculatePageRanks | ( | ) |
Calculate/set the PageRanks for all the matching documents
Definition at line 740 of file Result.cpp.
References describeShortKey(), getPageRank(), getPrimaryKey(), OPENTREP_LOG_NOTIFICATION, OPENTREP::ScoreType::PAGE_RANK, OPENTREP::ScoreBoard::setScore(), and setScoreOnDocMap().
Referenced by OPENTREP::ResultHolder::calculatePageRanks().
void OPENTREP::Result::calculateHeuristicWeights | ( | ) |
Calculate/set the heuristic weights for all the matching documents
Definition at line 774 of file Result.cpp.
Referenced by 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 783 of file Result.cpp.
References OPENTREP::ScoreBoard::calculateCombinedWeight(), OPENTREP::ScoreBoard::describe(), describeShortKey(), getDocumentPair(), getPrimaryKey(), OPENTREP_LOG_DEBUG, setBestCombinedWeight(), setBestDocData(), setBestDocID(), OPENTREP::Filter::shouldKeep(), and OPENTREP::WordHolder::tokeniseStringIntoWordList().
Referenced by 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 toString().
|
virtual |
Read a Business Object from an input stream.
istream& | the input stream. |
Implements OPENTREP::BomAbstract.
Definition at line 102 of file Result.cpp.
|
virtual |
Get the serialised version of the Business Object.
Implements OPENTREP::BomAbstract.
Definition at line 65 of file Result.cpp.
References OPENTREP::ScoreBoard::describe(), and describeKey().
Referenced by fullTextMatch(), toStream(), 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 describeShortKey().
Referenced by 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.
Referenced by calculateCodeMatches(), calculateCombinedWeights(), calculateEnvelopeWeights(), calculatePageRanks(), describeKey(), and displayXapianPercentages().
|
friend |
Definition at line 49 of file Result.hpp.
|
friend |
Definition at line 50 of file Result.hpp.