Search Query. More...
#include <gsearchquery.h>
Private Member Functions | |
GSearchQueryNode * | AddORs (GSearchQueryNode *parent) |
void | TreatNode (GSearchQueryNode *node) |
void | TreatANDNode (GSearchQueryNode *node, R::RString &str) |
Private Attributes | |
GSession * | Session |
R::RContainer< R::RString, true, true > | Tokens |
R::RContainer< GConcept, false, true > | Concepts |
R::RContainer< R::RString, true, false > | Tmp |
R::RContainer< GConceptRef, true, true > | Found |
bool | OnlyAND |
int | Options |
R::RContainer< GConcept, false, true > | Stems |
R::RContainer< GLang, false, false > * | Langs |
GConceptExtractor * | Extractor |
size_t | Caller |
Additional Inherited Members | |
Protected Member Functions inherited from RTree< T, N, bAlloc > | |
RTree (void) | |
void | ClearNode (N *node) |
virtual void | Clear (void) |
N * | GetFirst (void) const |
N * | GetLast (void) const |
size_t | GetMaxDepth (void) const |
N * | GetTop (void) |
const N * | GetTop (void) const |
size_t | GetNbNodes (void) const |
size_t | GetNbTopNodes (void) const |
size_t | GetTab (N **tab, N *node, bool children=false) |
void | InsertNode (N *to, N *node) |
void | DeleteNodes (N *node, bool del=bAlloc) |
void | DeleteNode (N *node, bool del=bAlloc) |
void | UpdateDepth (N *node) |
void | MoveNode (N *to, N *node) |
void | Copy (const RTree< T, N, a > &src) |
void | DeepCopy (N *src, N *newparent) |
N * | GetNode (const TUse &tag) const |
double | GetUpOperationsCost (const N *u, const N *v) const |
virtual | ~RTree (void) |
Protected Attributes inherited from RTree< T, N, bAlloc > | |
N * | First |
N * | Last |
size_t | NbTopNodes |
size_t | NbNodes |
size_t | MaxDepth |
Detailed Description
Search Query.
The GSearchQuery class provides a representation for a structured query, that is a tree of query nodes, where each node is either an operator or a keyword.
A query may have multiple options as defined with tQueryOption.
Constructor & Destructor Documentation
GSearchQuery | ( | GSession * | session, |
GConceptExtractor * | extractor, | ||
size_t | caller, | ||
int | options = qoStems|qoKeywords|qoExpressions|qoReplace , |
||
R::RContainer< GLang, false, false > * | langs = 0 |
||
) |
Constructor of the query.
- Parameters
-
session Session. extractor Extractor. caller Identifier of the caller (for example a thread). options Options of the query. By default, all options are active. langs Pointer to a container of languages that must be use for the search. When null (default value), all languages are used.
~GSearchQuery | ( | void | ) |
Destructor.
Member Function Documentation
GSearchQueryNode* GetTop | ( | void | ) |
Get the top node of a query.
- Returns
- a pointer to a GSearchQueryNode.
const GSearchQueryNode* GetTop | ( | void | ) | const |
Get the top node of a query.
- Returns
- a pointer to a GSearchQueryNode.
bool UseOnlyAND | ( | void | ) | const |
Look if only the AND operator is used.
- Returns
- true if it is the case.
R::RCursor<R::RString> GetTokens | ( | void | ) | const |
Get the list of tokens.
- Returns
- a R;;RCursor.
size_t GetNbTokens | ( | void | ) | const |
- Returns
- the number of tokens.
R::RCursor<GConcept> GetConcepts | ( | size_t | min = 0 , |
size_t | max = SIZE_MAX |
||
) | const |
Get the list of concepts used in the query.
- Parameters
-
min Minimum position of the elements to iterate. max Maximum position of the elements to iterate (included max). If SZE_MAX, iterate until the end of the container.
- Returns
- a R;;RCursor.
size_t GetNbConcepts | ( | void | ) | const |
- Returns
- the number of concepts.
bool IsIn | ( | GConcept * | concept | ) | const |
Look if a given concept was used to formulate the query.
- Parameters
-
concept Concept to search for.
- Returns
- true if the concept was used.
|
virtual |
Build the query based on a string. By default, it is analyses the string in order to create the tree. In practice, the query is parsed from left to right.
- Parameters
-
query Query submitted.
void InsertNode | ( | GSearchQueryNode * | parent, |
GSearchQueryNode * | node | ||
) |
Insert a token in the query tree.
- Parameters
-
parent Parent token. node Token to add.
void MoveNode | ( | GSearchQueryNode * | to, |
GSearchQueryNode * | node | ||
) |
Move a token in the query tree.
- Parameters
-
to Future parent token. node Token to add.
|
virtual |
Create a new node corresponding to a string.
- Parameters
-
token String containing the token. type Type of the token.
- Returns
- a pointer that will be inserted in the query tree.
|
virtual |
Create a new node corresponding to a given concept.
- Parameters
-
concept Concept. type Type of the token.
- Returns
- a pointer that will be inserted in the query tree.
|
virtual |
Create a new node corresponding to an operator.
- Parameters
-
op Operator.
- Returns
- a pointer that will be inserted in the query tree.
R::RString ClearString | ( | const R::RString & | str | ) |
Clear a string. In practice, the leading and ending spaces are removed. If the string is an expression, the corresponding parentheses are removed.
- Parameters
-
str String to clear.
- Returns
- the string cleared.
bool CreateToken | ( | GSearchQueryNode * | parent, |
const R::RString & | str | ||
) |
Create the nodes appearing in a given string. The method is called recursively to obtain the whole query.
- Parameters
-
parent Parent node (if null, it is the top node). str String to analyze.
- Returns
- true if a node was created for the string passed.
GSearchQueryNode* CreateToken | ( | GSearchQueryNode * | parent, |
const R::RString & | token, | ||
GSearchToken::tType | type, | ||
bool | multiple | ||
) |
Create a token and insert it in the query tree. Eventually, if the token is a keyword, stems are used as alternatives and combine with the OR operator.
- Parameters
-
parent Parent token. token String representing the keyword. type Type of the token multiple In the case of a keyword, are there multiple terms.
- Returns
- a pointer to the node was inserted in the query tree.
|
private |
Insert different alternatives (OR operator) to a given node based on the container Found.
- Parameters
-
parent parent node.
- Returns
- a pointer to the last created search node.
|
private |
Treat a node to find an AND that can create an expression.
- Parameters
-
node Node to treat.
|
private |
Build all the possible expressions that results from the combinations of the keywords linked by AND operators.
- Parameters
-
node Node to treat. str String containing thz different concepts.
Member Data Documentation
|
private |
Session launching the query.
|
private |
Tokens given in the query.
|
private |
Container of all concepts.
|
private |
Temporary container of strings.
|
private |
Container to store some concepts found in the query.
|
private |
AND is the only operator used in the query.
|
private |
Options of the query.
|
private |
Temporary concepts.
|
private |
Languages used for the stemming if necessary.
|
private |
Extractor.
|
private |
Identifier of the caller.