Concepts Tree. More...
#include <gconcepttree.h>
Public Member Functions | |
GConceptTree (const GConceptTree &tree) | |
GConceptTree (size_t docid, const R::RContainer< GConceptRecord, false, true > &records, size_t nbtoprecords, size_t nbrefs) | |
GConceptTree (size_t docid, size_t max, size_t nb) | |
void | Verify (size_t docid, size_t max, size_t nb) |
GConceptNode * | InsertNode (GConceptNode *parent, tTokenType type, size_t conceptid, size_t synpos, size_t pos, size_t depth) |
virtual void | Clear (void) |
size_t | GetDocId (void) const |
size_t | GetNbNodes (void) const |
size_t | GetNbTopNodes (void) const |
size_t | GetNbRefs (void) const |
R::RCursor< GConceptNode > | GetNodes (GConcept *concept) const |
R::RCursor< GConceptNode > | GetNodes (size_t min=0, size_t max=SIZE_MAX) const |
const GConceptNode * | GetNode (size_t synpos) const |
const GConceptNode * | GetNearestNode (size_t synpos) const |
const GConceptNode * | GetNearestNode (size_t synpos, bool after) const |
const GConceptNode * | GetRoot (const GConceptNode *node1, const GConceptNode *node2) const |
size_t | GetMinPos (const GConceptNode *node, size_t nbbefore) const |
size_t | GetMaxPos (const GConceptNode *node, size_t nbafter) const |
size_t | GetMaxPos (void) const |
size_t | GetMaxSyntacticPos (void) const |
void | Print (void) const |
~GConceptTree (void) | |
Private Member Functions | |
void | TreatChildNode (R::RCursor< GConceptRecord > &record, GConceptNode *parent) |
void | CopyNode (GConceptNode *parent, GConceptNode *node) |
Private Member Functions inherited from RTree< T, N, bAlloc > | |
RTree (void) | |
void | ClearNode (N *node) |
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) |
Private Member Functions inherited from RContainer< GConceptNode, true, false > | |
RContainer (size_t m, size_t i=0) | |
RContainer (const RContainer< GConceptNode, true, false > &src) | |
RContainer (const RContainer< GConceptNode, false, false > &src) | |
int | Compare (const RContainer< GConceptNode, true, false > &) const |
size_t | GetNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetMaxNb (void) const |
size_t | GetIncNb (void) const |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Exchange (size_t pos1, size_t pos2) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (RContainer< GConceptNode, a, o > &src) |
RContainer & | operator= (const RContainer< GConceptNode, true, false > &src) |
RContainer & | operator= (const RContainer< GConceptNode, false, false > &src) |
void | Copy (const RContainer< GConceptNode, a, false > &src) |
RContainer & | operator+= (const RContainer< GConceptNode, a, o > &src) |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
const GConceptNode * | operator[] (size_t idx) const |
GConceptNode * | operator[] (size_t idx) |
const GConceptNode * | GetPtrAt (size_t idx) const |
GConceptNode * | GetPtrAt (size_t idx) |
GConceptNode * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
GConceptNode * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
GConceptNode * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
GConceptNode * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
GConceptNode * | GetInsertPtrAt (const TUse &tag, size_t pos) |
RContainer< GConceptNode, false, false > * | GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const GConceptNode **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (GConceptNode **tab, size_t min=0, size_t max=0) |
void | InsertPtrAt (GConceptNode *ins, size_t pos, bool del) |
void | InsertPtrAt (GConceptNode *ins, size_t pos) |
void | InsertPtr (GConceptNode *ins, bool del=false, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | Inter (const iRContainer< GConceptNode > &src1, const iRContainer< GConceptNode > &src2) |
void | Union (const iRContainer< GConceptNode > &src1, const iRContainer< GConceptNode > &src2) |
virtual | ~RContainer (void) |
Private Member Functions inherited from iRContainer< C > | |
size_t | GetNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetMaxNb (void) const |
size_t | GetIncNb (void) const |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Exchange (size_t pos1, size_t pos2) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (iRContainer< C > &src) |
iRContainer & | operator= (const iRContainer< C > &src) |
void | Copy (const iRContainer< C > &src) |
iRContainer & | operator+= (const iRContainer< C > &src) |
size_t | GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
const C * | GetPtrAt (size_t idx) const |
C * | GetPtrAt (size_t idx) |
C * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
C * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
C * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
C * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
C * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const C **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (C **tab, size_t min=0, size_t max=0) |
void | InsertPtrAt (C *ins, size_t pos, bool del) |
void | InsertPtrAt (C *ins, size_t pos) |
void | InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | Inter (const iRContainer< C > &src1, const iRContainer< C > &src2) |
void | Union (const iRContainer< C > &src1, const iRContainer< C > &src2) |
virtual | ~iRContainer (void) |
void | Create (const iRContainer< C > &src) |
iRContainer & | NormalCopy (const iRContainer< C > &src) |
void | DeepCopy (const iRContainer< C > &src) |
iRContainer & | Add (const iRContainer< C > &src) |
Private Attributes | |
R::RContainer< GConceptNode, false, false > | Pos |
R::RContainer< GConceptNodes, true, true > | Refs |
size_t | DocId |
Private Attributes inherited from RTree< T, N, bAlloc > | |
N * | First |
N * | Last |
size_t | NbTopNodes |
size_t | NbNodes |
size_t | MaxDepth |
Private Attributes inherited from iRContainer< C > | |
C ** | Tab |
size_t | NbPtr |
size_t | MaxPtr |
size_t | LastPtr |
size_t | IncPtr |
Additional Inherited Members | |
Static Private Member Functions inherited from RContainer< GConceptNode, true, false > | |
static int | SortOrder (const void *a, const void *b) |
Static Private Member Functions inherited from iRContainer< C > | |
static int | SortOrder (const void *a, const void *b) |
Detailed Description
Concepts Tree.
The GConceptTree implements a tree of concepts, each concept may appear at multiple depths in the tree. It means to represent documents which have, by nature, a structured organization. A XML documents for example is a tree of tags, attributes and texts.
In practice, the internal implementation supposes that:
- Each node (GConceptNode) represents a concept occurrence at a given position and a given depth in the object represented.
- A container stores all created nodes. It is responsible for the allocation and deallocation of the nodes. The idea is that the created nodes are only deallocated in the destructor.
- A container where the nodes are ordered by syntactic positions.
- A container stores all concepts appearing in a document and a pointer to all occurrences.
Constructor & Destructor Documentation
GConceptTree | ( | const GConceptTree & | tree | ) |
Copy constructor.
- Parameters
-
tree Source tree.
GConceptTree | ( | size_t | docid, |
const R::RContainer< GConceptRecord, false, true > & | records, | ||
size_t | nbtoprecords, | ||
size_t | nbrefs | ||
) |
Construct a tree from a given set of records.
- Parameters
-
docid Document identifier. records Container of records. nbrecords Number of records used for the document tree. nbrefs Number of concepts referenced.
GConceptTree | ( | size_t | docid, |
size_t | max, | ||
size_t | nb | ||
) |
constructor.
- Parameters
-
docid Document identifier. max Maximum number of initial nodes to create. nb Initial size of the concept reference container.
~GConceptTree | ( | void | ) |
Destructor.
Member Function Documentation
void Verify | ( | size_t | docid, |
size_t | max, | ||
size_t | nb | ||
) |
Verify that the container may hold a given number of nodes and concept references. The structure is also emptied.
- Parameters
-
docid Document identifier. max Number of nodes. nb Number of the concept references.
|
private |
Treat the next elements in the cursor as possible children.
- Parameters
-
record Cursor. parent Parent node.
|
private |
Copy a node from one tree to the other one.
- Parameters
-
parent Parent node that will contain the node copied. node Node to copy.
GConceptNode* InsertNode | ( | GConceptNode * | parent, |
tTokenType | type, | ||
size_t | conceptid, | ||
size_t | synpos, | ||
size_t | pos, | ||
size_t | depth | ||
) |
Insert a node in the tree.
- Parameters
-
parent Parent node. If Null, it is supposed to be a top node. type Type of the token. conceptid Concept identifier associated with the node. synpos Syntactic position. pos Position in the object. depth Depth of the concept.
- Returns
- Pointer to a node created.
|
virtual |
Clear the structure (but the main container).
Reimplemented from RTree< T, N, bAlloc >.
size_t GetDocId | ( | void | ) | const |
- Returns
- the identifier of the document.
size_t GetNbNodes | ( | void | ) | const |
- Returns
- the total number of nodes in the tree.
size_t GetNbTopNodes | ( | void | ) | const |
- Returns
- the total number of top nodes in the tree.
size_t GetNbRefs | ( | void | ) | const |
- Returns
- the total number of concepts references.
R::RCursor<GConceptNode> GetNodes | ( | GConcept * | concept | ) | const |
Get all the nodes representing the occurrences of a given concept.
- Parameters
-
concept Concept.
- Returns
- a cursor over the nodes.
R::RCursor<GConceptNode> GetNodes | ( | size_t | min = 0 , |
size_t | max = SIZE_MAX |
||
) | const |
Get all the nodes ordered by syntactic position.
- Parameters
-
min Minimum position of the elements to iterate. max Maximum position of the elements to iterate (included max). If SIZE_MAX, iterate until the end of the container.
- Returns
- a cursor over the nodes.
const GConceptNode* GetNode | ( | size_t | synpos | ) | const |
Get the node at a given syntactic position.
- Parameters
-
synpos Syntactic position.
- Returns
- a pointer or null if the position is outside the tree.
const GConceptNode* GetNearestNode | ( | size_t | synpos | ) | const |
Get the nearest node at a given syntactic position. In practice, the method searches alternatively before and after the given position.
- Parameters
-
synpos Syntactic position.
- Returns
- a pointer or null if the position is outside the tree.
const GConceptNode* GetNearestNode | ( | size_t | synpos, |
bool | after | ||
) | const |
Get the nearest node at a given syntactic position. In practice, the method searches the first node after or before the given position. If no node is found, it searches in the order direction.
- Parameters
-
synpos Syntactic position. after Search after the position (true) or before it (false)?
- Returns
- a pointer or null if the position is outside the tree.
const GConceptNode* GetRoot | ( | const GConceptNode * | node1, |
const GConceptNode * | node2 | ||
) | const |
Find the root node (the most common highest node) of two nodes. If at least one of the node doesn't have a parent, no root node can be found.
- Parameters
-
node1 First node. node2 Second node.
- Returns
- the root node of 0 if both nodes are top nodes.
size_t GetMinPos | ( | const GConceptNode * | node, |
size_t | nbbefore | ||
) | const |
Find the minimal position centred on a given node and a number of nodes before.
- Parameters
-
node Concept node. nbbefore Maximum number of concept node before.
- Returns
- a position.
size_t GetMaxPos | ( | const GConceptNode * | node, |
size_t | nbafter | ||
) | const |
Find the maximal position centred on a given node and a number of nodes after.
- Parameters
-
node Concept node. nbafter Maximum number of concept node after.
- Returns
- a position.
size_t GetMaxPos | ( | void | ) | const |
Compute the maximal position occupied by a referenced node.
- Returns
- a size_t.
size_t GetMaxSyntacticPos | ( | void | ) | const |
Compute the maximal syntactic position occupied by a referenced node.
- Returns
- a size_t.
void Print | ( | void | ) | const |
Simply print the information of all nodes on the screen;
Member Data Documentation
|
private |
Concept ordered by syntactic positions.
|
private |
Concept references.
|
private |
Document identifier.