Generic Search Engine. More...

#include <gengine.h>

Inheritance diagram for GEngine:
[legend]

Public Member Functions

 GEngine (GSession *session, GPlugInFactory *fac)
 
virtual void ApplyConfig (void)
 
virtual void Clear (GMetaEngine *metaengine, GSearchQuery *query, size_t caller)
 
GDocFragmentRankAddResult (GDoc *doc, const GConceptRecord *rec, size_t pos, size_t spos, size_t first, size_t last, double ranking, size_t caller)
 
GDocFragmentRankAddResult (size_t docid, const GConceptRecord *rec, size_t spos, size_t pos, size_t first, size_t last, double ranking, size_t caller)
 
GDocFragmentRankAddResult (GDocFragment *fragment, double ranking, size_t caller)
 
void Request (GSearchQuery *query, size_t caller)
 
GMetaEngineGetMetaEngine (void) const
 
double GetWeight (void) const
 
R::RCursor< GDocFragmentRankGetResults (size_t caller)
 
size_t GetNbResults (size_t caller) const
 
size_t GetTabResults (const GDocFragmentRank **tab, size_t caller) const
 
size_t GetTabResults (GDocFragmentRank **tab, size_t caller)
 
virtual void CreateConfig (void)
 
virtual ~GEngine (void)
 
- Public Member Functions inherited from GPlugIn
 GPlugIn (GSession *session, GPlugInFactory *fac)
 
void InsertParam (R::RParam *param)
 
template<class T >
T * FindParam (const R::RString &name)
 
R::RCursor< R::RParamGetParams (const R::RString &cat=R::RString::Null)
 
void GetCategories (R::RContainer< R::RString, true, false > &cats)
 
virtual void Init (void)
 
virtual void Reset (void)
 
GPlugInFactoryGetFactory (void) const
 
int Compare (const GPlugIn &plugin) const
 
int Compare (const R::RString &plugin) const
 
R::RString GetName (void) const
 
R::RString GetDesc (void) const
 
GSessionGetSession (void) const
 
virtual void Done (void)
 
virtual ~GPlugIn (void)
 

Protected Attributes

double Weight
 
- Protected Attributes inherited from GPlugIn
GPlugInFactoryFactory
 
GSessionSession
 
size_t Id
 

Private Member Functions

virtual void PerformRequest (GSearchQuery *query, size_t caller)=0
 

Private Attributes

R::RContainer
< GDocFragmentRank, false,
false > 
Results
 
GComputeRankRanking
 
R::RString RankingMethod
 
GMetaEngineMetaEngine
 

Detailed Description

Generic Search Engine.

The GEngine class provides a representation for a generic search engine. An engine plug-in may :

  • Make a direct search in the actual corpus of the session.
  • Call an external engine (for example Google Search), create a document in the session and process the results.
  • Call a ranking algorithm to compute the rankings of the results.

In practice, a search engine performs two steps:

  1. It calls the PerformRequest(GSearchQuery*) method. It is a pure virtual one that must be written by inheriting classes.
  2. If a ranking algorithm is associated to the engine, it is called after the query is treated through the GComputeRank::Rank(GEngine*) method. In practice, the ranking algorithm is supposed to modify the rankings of the fragments added as results through the 'AddResults' methods.

Each time a engine wants to add a results, it must call the one of the AddResult methods.

It is the role of inheriting classes to ensure that the query submitted to an external search engine respects its constraints. In particular, it must probably formulate a new compatible query based on the one used in GALILEI.

Warning
The ranking, $ranking$, associated by a given search engine must respect the constraint: $0\leq ranking \leq 1$. Otherwise, an exception is generated. This constraint ensures that each engine normalises its rankings. Without this normalisation, rankings from different engines cannot be compared.

See the documentation related to GPlugIn for more general information.

Constructor & Destructor Documentation

GEngine ( GSession session,
GPlugInFactory fac 
)

Construct an engine plug-in.

Parameters
sessionSession.
facFactory.
virtual ~GEngine ( void  )
virtual

Destructor of the search engine.

Member Function Documentation

virtual void ApplyConfig ( void  )
virtual

Configuration parameters were changed (or loaded).

Reimplemented from GPlugIn.

virtual void Clear ( GMetaEngine metaengine,
GSearchQuery query,
size_t  caller 
)
virtual

Clear the engine before a new request is send. By default, the results are cleared and the MetaEngine variable is set.

Parameters
metaengineMeta-engine that will query the engine.
queryQuery.
callerIdentifier of the caller (for example a thread).
GDocFragmentRank* AddResult ( GDoc doc,
const GConceptRecord rec,
size_t  pos,
size_t  spos,
size_t  first,
size_t  last,
double  ranking,
size_t  caller 
)

Add a fragment from a known document as result to the meta-engine. In practice, it adds an entry to the container of results.

Parameters
docDocument.
recConcept record.
posPosition to the fragment to extract.
sposSyntactic position of the fragment centre.
firstFirst concept found.
lastLast concept found.
rankingRanking of the document given by the engine ( $0\leq ranking \leq 1$). When a ranking algorithm is associated to the engine, it will overwrite this ranking.
callerIdentifier of the caller (for example a thread).
Warning
The deallocation of the record must be managed by the caller.
Returns
a pointer to a GDocFragment.
GDocFragmentRank* AddResult ( size_t  docid,
const GConceptRecord rec,
size_t  spos,
size_t  pos,
size_t  first,
size_t  last,
double  ranking,
size_t  caller 
)

Add a fragment from a known document as result to the meta-engine. In practice, it adds an entry to the container of results.

Parameters
docidIdentifier of the document.
recConcept record.
posPosition to the fragment to extract.
sposSyntactic position of the fragment centre.
firstFirst concept found.
lastLast concept found.
rankingRanking of the document given by the engine ( $0\leq ranking \leq 1$). When a ranking algorithm is associated to the engine, it will overwrite this ranking.
callerIdentifier of the caller (for example a thread).
Warning
The deallocation of the record must be managed by the caller.
Returns
a pointer to a GDocFragment.
GDocFragmentRank* AddResult ( GDocFragment fragment,
double  ranking,
size_t  caller 
)

Add a fragment from a known document as result to the meta-engine. In practice, it adds an entry to the container of results.

Parameters
fragmentFragment to add.
rankingRanking of the document given by the engine ( $0\leq ranking \leq 1$). When a ranking algorithm is associated to the engine, it will overwrite this ranking.
callerIdentifier of the caller (for example a thread).
Warning
The deallocation of the record must be managed by the caller.
Returns
a pointer to a GDocFragment.
virtual void PerformRequest ( GSearchQuery query,
size_t  caller 
)
privatepure virtual

Request a query.

Parameters
queryQuery.
callerIdentifier of the caller (for example a thread).
void Request ( GSearchQuery query,
size_t  caller 
)

Treat a request. It is the responsibility of the meta-search engine to build a syntactically correct query for the particular search engine.

Parameters
queryQuery.
callerIdentifier of the caller (for example a thread).
GMetaEngine* GetMetaEngine ( void  ) const

Get the meta-engine that calls the engine (may be null if no meta-engine is runned).

Returns
a pointer to a GMetaEngine.
double GetWeight ( void  ) const
Returns
the weight associated to the engine
R::RCursor<GDocFragmentRank> GetResults ( size_t  caller)

Get all the fragments retrieved by the engine.

Parameters
callerIdentifier of the caller (for example a thread).
Returns
a cursor on GDocFragmentRank.
size_t GetNbResults ( size_t  caller) const

Get the number of document fragments selected by the engine.

Parameters
callerIdentifier of the caller (for example a thread).
Returns
the number of document fragments.
size_t GetTabResults ( const GDocFragmentRank **  tab,
size_t  caller 
) const

Get an array of the document fragments selected by the engine.

Parameters
tabArray that will hold the results.
callerIdentifier of the caller (for example a thread).
Returns
the number of document fragments.
size_t GetTabResults ( GDocFragmentRank **  tab,
size_t  caller 
)

Get an array of the document fragments selected by the engine.

Parameters
tabArray that will hold the results.
callerIdentifier of the caller (for example a thread).
Returns
the number of document fragments.
virtual void CreateConfig ( void  )
virtual

Create the configuration (attached to the session).

Reimplemented from GPlugIn.

Member Data Documentation

R::RContainer<GDocFragmentRank,false,false> Results
private

All document fragments.

GComputeRank* Ranking
private

Ranking method associated to the engine.

R::RString RankingMethod
private

Name of the ranking method used.

GMetaEngine* MetaEngine
private

Meta engine that calls the engine.

double Weight
protected

Weight associated to the engine.