Generic Search Engine. More...
#include <gengine.h>
Public Member Functions | |
GEngine (GSession *session, GPlugInFactory *fac) | |
virtual void | ApplyConfig (void) |
virtual void | Clear (GMetaEngine *metaengine, GSearchQuery *query, size_t caller) |
GDocFragmentRank * | AddResult (GDoc *doc, const GConceptRecord *rec, size_t pos, size_t spos, size_t first, size_t last, double ranking, size_t caller) |
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) |
GDocFragmentRank * | AddResult (GDocFragment *fragment, double ranking, size_t caller) |
void | Request (GSearchQuery *query, size_t caller) |
GMetaEngine * | GetMetaEngine (void) const |
double | GetWeight (void) const |
R::RCursor< GDocFragmentRank > | GetResults (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::RParam > | GetParams (const R::RString &cat=R::RString::Null) |
void | GetCategories (R::RContainer< R::RString, true, false > &cats) |
virtual void | Init (void) |
virtual void | Reset (void) |
GPlugInFactory * | GetFactory (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 |
GSession * | GetSession (void) const |
virtual void | Done (void) |
virtual | ~GPlugIn (void) |
Protected Attributes | |
double | Weight |
Protected Attributes inherited from GPlugIn | |
GPlugInFactory * | Factory |
GSession * | Session |
size_t | Id |
Private Member Functions | |
virtual void | PerformRequest (GSearchQuery *query, size_t caller)=0 |
Private Attributes | |
R::RContainer < GDocFragmentRank, false, false > | Results |
GComputeRank * | Ranking |
R::RString | RankingMethod |
GMetaEngine * | MetaEngine |
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:
- It calls the PerformRequest(GSearchQuery*) method. It is a pure virtual one that must be written by inheriting classes.
- 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, , associated by a given search engine must respect the constraint: . 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
-
session Session. fac Factory.
|
virtual |
Destructor of the search engine.
Member Function Documentation
|
virtual |
Configuration parameters were changed (or loaded).
Reimplemented from GPlugIn.
|
virtual |
Clear the engine before a new request is send. By default, the results are cleared and the MetaEngine variable is set.
- Parameters
-
metaengine Meta-engine that will query the engine. query Query. caller Identifier 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
-
doc Document. rec Concept record. pos Position to the fragment to extract. spos Syntactic position of the fragment centre. first First concept found. last Last concept found. ranking Ranking of the document given by the engine ( ). When a ranking algorithm is associated to the engine, it will overwrite this ranking. caller Identifier 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
-
docid Identifier of the document. rec Concept record. pos Position to the fragment to extract. spos Syntactic position of the fragment centre. first First concept found. last Last concept found. ranking Ranking of the document given by the engine ( ). When a ranking algorithm is associated to the engine, it will overwrite this ranking. caller Identifier 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
-
fragment Fragment to add. ranking Ranking of the document given by the engine ( ). When a ranking algorithm is associated to the engine, it will overwrite this ranking. caller Identifier 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.
|
privatepure virtual |
Request a query.
- Parameters
-
query Query. caller Identifier 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
-
query Query. caller Identifier 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
-
caller Identifier 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
-
caller Identifier 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
-
tab Array that will hold the results. caller Identifier 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
-
tab Array that will hold the results. caller Identifier of the caller (for example a thread).
- Returns
- the number of document fragments.
|
virtual |
Create the configuration (attached to the session).
Reimplemented from GPlugIn.
Member Data Documentation
|
private |
All document fragments.
|
private |
Ranking method associated to the engine.
|
private |
Name of the ranking method used.
|
private |
Meta engine that calls the engine.
|
protected |
Weight associated to the engine.