OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OPENTREP::Result Class Reference

Class wrapping a set of Xapian documents having matched a given query string. More...

#include <opentrep/bom/Result.hpp>

+ Inheritance diagram for OPENTREP::Result:

Public Member Functions

const TravelQuery_TgetQueryString () const
 
const TravelQuery_TgetCorrectedTravelQuery () const
 
bool hasFullTextMatched () const
 
const NbOfErrors_TgetEditDistance () const
 
const NbOfErrors_TgetAllowableEditDistance () const
 
const DocumentList_TgetDocumentList () const
 
const DocumentMap_TgetDocumentMap () const
 
const XapianDocumentPair_TgetDocumentPair (const Xapian::docid &) const
 
const Xapian::Document & getDocument (const Xapian::docid &) const
 
const Xapian::docid & getBestDocID () const
 
const Percentage_TgetBestCombinedWeight () const
 
const RawDataString_TgetBestDocData () 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
 

Detailed Description

Class wrapping a set of Xapian documents having matched a given query string.

Definition at line 48 of file Result.hpp.

Member Function Documentation

const TravelQuery_T& OPENTREP::Result::getQueryString ( ) const
inline

Get the query string.

Definition at line 56 of file Result.hpp.

const TravelQuery_T& OPENTREP::Result::getCorrectedTravelQuery ( ) const
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().

bool OPENTREP::Result::hasFullTextMatched ( ) const
inline

State whether there has been a full-text match.

Definition at line 71 of file Result.hpp.

Referenced by OPENTREP::createPlaces().

const NbOfErrors_T& OPENTREP::Result::getEditDistance ( ) const
inline

Get the edit distance/error, with which the matching has been made.

Definition at line 78 of file Result.hpp.

const NbOfErrors_T& OPENTREP::Result::getAllowableEditDistance ( ) const
inline

Get the maximal allowable edit distance/error, with which the matching has been made.

Definition at line 86 of file Result.hpp.

const DocumentList_T& OPENTREP::Result::getDocumentList ( ) const
inline

Get the list of documents.

Definition at line 93 of file Result.hpp.

const DocumentMap_T& OPENTREP::Result::getDocumentMap ( ) const
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().

const Xapian::docid& OPENTREP::Result::getBestDocID ( ) const
inline

Get the Xapian ID of the best matching document.

Definition at line 118 of file Result.hpp.

const Percentage_T& OPENTREP::Result::getBestCombinedWeight ( ) const
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().

const RawDataString_T& OPENTREP::Result::getBestDocData ( ) const
inline

Get the details of the best matching document.

Definition at line 132 of file Result.hpp.

Referenced by OPENTREP::createPlaces().

const Xapian::Document& OPENTREP::Result::getBestXapianDocument ( ) const
inline

Get the best matching Xapian document.

Definition at line 139 of file Result.hpp.

References getDocument().

void OPENTREP::Result::setQueryString ( const TravelQuery_T iQueryString)
inline

Set the query string.

Definition at line 149 of file Result.hpp.

void OPENTREP::Result::setCorrectedQueryString ( const TravelQuery_T iCorrectedQueryString)
inline

Set the corrected query string.

Definition at line 156 of file Result.hpp.

void OPENTREP::Result::setHasFullTextMatched ( const bool  iHasFullTextMatched)
inline

Set whether there has been a full-text match.

Definition at line 163 of file Result.hpp.

void OPENTREP::Result::setEditDistance ( const NbOfErrors_T iEditDistance)
inline

Set the edit distance/error, with which the matching has been made.

Definition at line 170 of file Result.hpp.

void OPENTREP::Result::setAllowableEditDistance ( const NbOfErrors_T iAllowableEditDistance)
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.

Note
The score type is not specified, as it is corresponding, by construction, to the (Xapian-based) full-text matching. Indeed, when there is no (Xapian-based) full-text matching, by construction, no Xapian document has been found matching a given string.
Parameters
constXapian::Document& The Xapian document to be added.
constScore_T& The matching percentage.

Definition at line 141 of file Result.cpp.

References OPENTREP::ScoreType::XAPIAN_PCT.

Referenced by fillResult().

void OPENTREP::Result::setBestDocID ( const Xapian::docid &  iDocID)
inline

Set the Xapian ID of the best matching document.

Definition at line 207 of file Result.hpp.

Referenced by calculateCombinedWeights().

void OPENTREP::Result::setBestCombinedWeight ( const Percentage_T iPercentage)
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().

void OPENTREP::Result::setBestDocData ( const std::string &  iDocData)
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.

Parameters
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
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.

Parameters
constXapian::Database& The Xapian index/database.
constTravelQuery_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().

Location OPENTREP::Result::retrieveLocation ( const Xapian::Document &  iDocument)
static

Parse the raw data, as stored by the given Xapian document, and holding all the details of a POR (point of reference).

Parameters
constXapian::Document& The Xapian document.
Returns
Location The Location structure holding all the details of the place/POR (point of reference).

Definition at line 266 of file Result.cpp.

Referenced by OPENTREP::createPlaces(), getEnvelopeID(), getPageRank(), and getPrimaryKey().

Location OPENTREP::Result::retrieveLocation ( const RawDataString_T iRawDataString)
static

Parse the raw data, as stored by a typical Xapian document, and holding all the details of a POR (point of reference).

Parameters
constRawDataString_T& The Xapian document data.
Returns
Location The Location structure holding all the details of the place/POR (point of reference).

Definition at line 252 of file Result.cpp.

References OPENTREP::PORStringParser::generateLocation().

LocationKey OPENTREP::Result::getPrimaryKey ( const Xapian::Document &  iDocument)
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.

Parameters
Xapian::Document&The Xapian document.
Returns
LocationKey& The primary key of the place/POR (point of reference).

Definition at line 278 of file Result.cpp.

References OPENTREP::Location::getKey(), and retrieveLocation().

Referenced by calculateCodeMatches(), calculateCombinedWeights(), calculateEnvelopeWeights(), calculatePageRanks(), and displayXapianPercentages().

Score_T OPENTREP::Result::getEnvelopeID ( const Xapian::Document &  iDocument)
static

Extract the Envelope ID from the data of the given Xapian document.

The retrieveLocation() is used to parse the Xapian document raw data.

Parameters
Xapian::Document&The Xapian document.
Returns
Score_T& The Envelope ID of the place/POR (point of reference), converted into a floating point (from an integer value).

Definition at line 289 of file Result.cpp.

References OPENTREP::Location::getEnvelopeID(), and retrieveLocation().

Referenced by calculateEnvelopeWeights().

PageRank_T OPENTREP::Result::getPageRank ( const Xapian::Document &  iDocument)
static

Extract the PageRank from the data of the given Xapian document.

The retrieveLocation() is used to parse the Xapian document raw data.

Parameters
Xapian::Document&The Xapian document.
Returns
PageRank_T& The PageRank of the place/POR (point of reference).

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.

Parameters
constXapian::docid& Document ID for the Xapian document
constScoreType& Score type
constScore_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::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 ( )
void OPENTREP::Result::toStream ( std::ostream &  ioOut) const
virtual

Dump a Business Object into an output stream.

Parameters
ostream&the output stream.

Implements OPENTREP::BomAbstract.

Definition at line 97 of file Result.cpp.

References toString().

void OPENTREP::Result::fromStream ( std::istream &  ioIn)
virtual

Read a Business Object from an input stream.

Parameters
istream&the input stream.

Implements OPENTREP::BomAbstract.

Definition at line 102 of file Result.cpp.

std::string OPENTREP::Result::toString ( ) const
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().

std::string OPENTREP::Result::describeKey ( ) const
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().

std::string OPENTREP::Result::describeShortKey ( ) const
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().

Friends And Related Function Documentation

friend class FacResultHolder
friend

Definition at line 49 of file Result.hpp.

friend class FacResult
friend

Definition at line 50 of file Result.hpp.


The documentation for this class was generated from the following files: