Meta-search Engine. More...

#include <gmetaengine.h>

Inheritance diagram for GMetaEngine:
[legend]

Classes

class  Internal
 

Public Member Functions

 GMetaEngine (GSession *session, GPlugInFactory *fac)
 
virtual void Init (void)
 
virtual GSearchQueryBuildQuery (const R::RString query, size_t caller)
 
void Request (GSearchQuery *query, size_t caller)
 
R::RCursor< GDocRefGetResultsByDocs (size_t caller)
 
R::RCursor< GDocFragmentRanksGetResults (size_t caller)
 
size_t GetNbResults (size_t caller)
 
virtual void Done (void)
 
virtual ~GMetaEngine (void)
 
- Public Member Functions inherited from GPlugIn
 GPlugIn (GSession *session, GPlugInFactory *fac)
 
virtual void ApplyConfig (void)
 
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 CreateConfig (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 ~GPlugIn (void)
 

Protected Member Functions

virtual GConceptExtractorCreateConceptExtractor (void)
 
GConceptExtractorGetExtractor (void) const
 
virtual void FragmentRankAdded (GDocFragmentRank *rank, GEngine *engine, size_t caller)
 
virtual void PrepareRequest (GSearchQuery *query, size_t caller)
 
virtual void RequestEngines (GSearchQuery *query, size_t caller)
 
virtual void ComputeGlobalRanking (size_t caller)
 
virtual void PostRequest (size_t caller)
 

Private Member Functions

GDocFragmentRankAddResult (GDoc *doc, const GConceptRecord *rec, size_t pos, size_t spos, size_t first, size_t last, double ranking, GEngine *engine, size_t caller)
 
GDocFragmentRankAddResult (size_t docid, const GConceptRecord *rec, size_t spos, size_t pos, size_t first, size_t last, double ranking, GEngine *engine, size_t caller)
 
- Private Member Functions inherited from RDownloadFile
 RDownloadFile (void)
 
void Download (const RURI &uri, const R::RURI &local)
 
- Private Member Functions inherited from RDownload
 RDownload (void)
 
void Download (const RURI &uri)
 
RString GetMIMEType (void)
 
virtual ~RDownload (void)
 

Private Attributes

R::RThreadLocalStorage< InternalData
 
GConceptExtractorExtractor
 

Additional Inherited Members

- Protected Attributes inherited from GPlugIn
GPlugInFactoryFactory
 
GSessionSession
 
size_t Id
 

Detailed Description

Meta-search Engine.

The GMetaEngine class provides a representation for a generic meta-search engine. In practice, it manages the document fragments retrieved by the different engines. Internally, it maintains two containers:

  1. A container of document references, each document reference containing the document fragments retrieved.
  2. A global list of document fragments retrieved and ranked.

In practice, a meta-engine does the following thinks

  1. It calls the method PrepareRequest(GSearchQuery*). By default, it clears the old results and call GEngine::Clear(GMetaEngine*,GSearchQuery*) for each enabled engine.
  2. It calls the method RequestEngines(GSearchQuery*). By default, the method forwards the query passed to each enabled engine. Inheriting classes may redefine this method to adapt the query to each engine or to select specific engines. Each time a engine add a fragment as a result, the method FragmentRankAdded(GDocFragmentRank*,GEngine*) is called.
  3. It calls the method ComputeGlobalRanking(void) to compute a global ranking. This method should be overloaded by inheriting classes.
  4. The results are ranked by ascending ranking.
  5. It calls the method PostRequest(void). By default, this method does nothing.

See the documentation related to GPlugIn for more general information.

Constructor & Destructor Documentation

GMetaEngine ( GSession session,
GPlugInFactory fac 
)

Construct a meta-engine.

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

Destructor of the meta-engine.

Member Function Documentation

virtual void Init ( void  )
virtual

Initialize the plug-in.

Reimplemented from GPlugIn.

GDocFragmentRank* AddResult ( GDoc doc,
const GConceptRecord rec,
size_t  pos,
size_t  spos,
size_t  first,
size_t  last,
double  ranking,
GEngine engine,
size_t  caller 
)
private

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.
engineEngine from which the result come.
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 GDocFragmentRank.
GDocFragmentRank* AddResult ( size_t  docid,
const GConceptRecord rec,
size_t  spos,
size_t  pos,
size_t  first,
size_t  last,
double  ranking,
GEngine engine,
size_t  caller 
)
private

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.
engineEngine from which the result come.
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 GDocFragmentRank.
virtual GConceptExtractor* CreateConceptExtractor ( void  )
protectedvirtual

Create an extractor.

Returns
a pointer to an extractor.
GConceptExtractor* GetExtractor ( void  ) const
protected

Get the extractor used.

Returns
a pointer to an extractor.
virtual void FragmentRankAdded ( GDocFragmentRank rank,
GEngine engine,
size_t  caller 
)
protectedvirtual

Method called each time an engine adds a given document fragment as a result. By default, the method does nothing.

Parameters
rankDocument fragment added.
engineEngine from which the result come.
callerIdentifier of the caller (for example a thread).
virtual void PrepareRequest ( GSearchQuery query,
size_t  caller 
)
protectedvirtual

Initialise the query. The containers are cleared and the method GEngine::Clear(GMetaEngine*) is called for each enabled engine.

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

Send a query to the engines. By default, it is send to all enabled engines.

Parameters
queryQuery.
callerIdentifier of the caller (for example a thread).
virtual void ComputeGlobalRanking ( size_t  caller)
protectedvirtual

This function is used to compute the global ranking for documents extracted from different search engines. Results are then sort using this global ranking

Parameters
callerIdentifier of the caller (for example a thread).
virtual void PostRequest ( size_t  caller)
protectedvirtual

Perform some tasks once the request was treated.

Parameters
callerIdentifier of the caller (for example a thread).
virtual GSearchQuery* BuildQuery ( const R::RString  query,
size_t  caller 
)
virtual

Build a search query. By default, it creates an object of the class QSearchQuery and build it. Moreover, the stems are used to expand the query.

Parameters
queryString representing the query.
callerIdentifier of the caller (for example a thread).
Returns
a pointer to a QSearchQuery.
void Request ( GSearchQuery query,
size_t  caller 
)

Send a query to the meta-search engine. It call GMetaEngine::PerformRequest and order then all the document fragments.

Parameters
queryQuery.
callerIdentifier of the caller (for example a thread).
R::RCursor<GDocRef> GetResultsByDocs ( size_t  caller)

Get all the fragments retrieved by documents.

Parameters
callerIdentifier of the caller (for example a thread).
Returns
a cursor on GDocRef.
R::RCursor<GDocFragmentRanks> GetResults ( size_t  caller)

Get all the fragments retrieved by documents.

Parameters
callerIdentifier of the caller (for example a thread).
Returns
a cursor on GDocRef.
size_t GetNbResults ( size_t  caller)
Returns
the number of results.
Parameters
callerIdentifier of the caller (for example a thread).
virtual void Done ( void  )
virtual

The method is called each time a session is closed.

Reimplemented from GPlugIn.

Member Data Documentation

Data used to store the results.

GConceptExtractor* Extractor
private

Extractor used.