Knowledge Base. More...

#include <gkb.h>

Inheritance diagram for GKB:
[legend]

Public Member Functions

virtual ~GKB (void)=0
 
General Methods

General methods.

tObjState GetState (void) const
 
GStorageGetStorage (void) const
 
Convenient Methods
GConceptTypeGetTokenType (void) const
 
GConceptTypeGetDCMIType (void) const
 
GConceptTypeGetURIType (void) const
 
GConceptTypeGetNamedEntityType (void) const
 
GConceptTypeGetTaxonomyType (void) const
 
GConceptGetContent (void) const
 
GConceptGetUnknown (void) const
 
GConceptGetURI (void) const
 
GConceptGetNamedEntity (void) const
 
GConceptGetIsA (void) const
 
GConceptGetSynonym (void) const
 
GConceptGetPartOf (void) const
 
Concept Type Methods

Methods related to the management of concept types.

size_t GetNbObjs (const GConceptType *obj) const
 
size_t GetMaxObjId (const GConceptType *obj) const
 
GConceptTypeGetObj (const GConceptType *obj, char id, bool null)
 
GConceptTypeGetObj (const GConceptType *obj, const R::RString &name, bool null)
 
R::RCursor< GConceptTypeGetObjs (const GConceptType *obj) const
 
GConceptTypeInsertObj (const GConceptType *obj, tConceptCat cat, size_t id, const R::RString &name, const R::RString &desc, bool &newone)
 
GConceptTypeInsertObj (const GConceptType *obj, tConceptCat cat, size_t id, const R::RString &name, const R::RString &desc)
 
GConceptTypeInsertObj (const GConceptType *obj, tConceptCat cat, const R::RString &name, const R::RString &desc, bool &newone)
 
GConceptTypeInsertObj (const GConceptType *obj, tConceptCat cat, const R::RString &name, const R::RString &desc)
 
Concept Methods

Methods related to the management of concepts.

size_t GetNbObjs (const GConcept *obj) const
 
size_t GetMaxObjId (const GConcept *obj) const
 
R::RCursor< GConceptGetObjs (const GConcept *obj) const
 
GConceptGetObj (const GConcept *obj, size_t id)
 
GConceptGetObj (const GConcept *obj, GConceptType *type, const R::RString &concept, bool null=false)
 
GConceptInsertObj (const GConcept *obj, GConceptType *type, const R::RString &concept, bool &newone)
 
GConceptInsertObj (const GConcept *obj, GConceptType *type, const R::RString &concept)
 
GConceptInsertObj (const GConcept &concept, bool &newone)
 
GConceptInsertObj (const GConcept &concept)
 
GConceptRenameObj (GConcept *concept, const R::RString &name)
 
void DeleteObj (GConcept *concept)
 
Statement Methods

Methods related to the management of statements.

GStatementGetObj (const GStatement *obj, size_t id, bool null=false)
 
GStatementGetObj (const GStatement *obj, GObject *subject, GObject *predicate, GObject *value, bool null=false)
 
GStatementInsertObj (const GStatement *obj, size_t id, GObject *subject, GObject *predicate, GObject *value, double weight, bool &newone)
 
GStatementInsertObj (const GStatement *obj, size_t id, GObject *subject, GObject *predicate, GObject *value, double weight)
 

Protected Member Functions

 GKB (GSession *session)
 
void ClearIndex (tObjType type)
 

Protected Attributes

GSessionSession
 
tObjState State
 
GStorageStorage
 
bool SaveResults
 
GConceptTypeTokenType
 
GConceptTypeDCMIType
 
GConceptTypeNamedEntityType
 
GConceptTypeURIType
 
GConceptTypeTaxonomyType
 
GConceptContent
 
GConceptNamedEntity
 
GConceptURI
 
GConceptIsA
 
GConceptSynonym
 
GConceptPartOf
 
GConceptUnknown
 
R::RObjectContainer
< GConceptType, true > 
ConceptTypes
 
R::RObjectHashContainer
< GConcept, true > 
Concepts
 
R::RContainer< GStatement,
true, false > 
StatementsByIds
 

Detailed Description

Knowledge Base.

The GKB represents the knowledge base. It is the basic building block for a session. In fact, all the methods defined here can only be called through a session instance.

It maintains:

Warning
Some methods use a reinterpret_cast<GSession*>(this) expression.

Constructor & Destructor Documentation

GKB ( GSession session)
protected

Constructor.

Parameters
sessionSession.
virtual ~GKB ( void  )
pure virtual

Destruct the session.

Member Function Documentation

tObjState GetState ( void  ) const

The knowlegde base may be in two states only :

  • osOnDemand if some information is loaded from the disk.
  • osLatest if the latest information was loaded to the disk.

When the knowledge base is in the osOnDemand state, it is not necessary to save something to the disk since an information is currently be loaded.

Returns
the state.
GStorage* GetStorage ( void  ) const
Returns
Pointer to storage manager.
GConceptType* GetTokenType ( void  ) const

Get the default concept type representing tokens.

Returns
a concept type.
GConceptType* GetDCMIType ( void  ) const

Get the default concept type representing the DMCI.

Returns
a concept type.
GConceptType* GetURIType ( void  ) const

Get the default type for URI.

Returns
a concept type.
GConceptType* GetNamedEntityType ( void  ) const

Get the default type for named entities.

Returns
a concept type.
GConceptType* GetTaxonomyType ( void  ) const

Get the default concept type that represents relations of taxonomies.

Returns
a concept type.
GConcept* GetContent ( void  ) const

Get the default meta-concept representing the default content.

Returns
a concept.
GConcept* GetUnknown ( void  ) const

Get the default "unknown" concept. This concept can be useful when, for example, a query is formulated with terms that don't exist in the dictionaries (i.e. no document contains them). This terms can then be assimilated to a "unknown" concept.

Remarks
The "Unknown" concept is associated to the default "text" type.
Returns
a concept.
GConcept* GetURI ( void  ) const

Get the meta-concept representing the default URI content.

Returns
a concept.
GConcept* GetNamedEntity ( void  ) const

Get the meta-concept representing the default named entities.

Returns
a concept.
GConcept* GetIsA ( void  ) const

Get the default concept that represents a "IsA" relation.

Returns
a concept.
GConcept* GetSynonym ( void  ) const

Get the default concept that represents a "synonym" relation.

Returns
a concept.
GConcept* GetPartOf ( void  ) const

Get the default concept that represents a "part of" relation.

Returns
a concept.
void ClearIndex ( tObjType  type)
protected

Clear the block index of all the concepts for a given object type.

Parameters
typeObject type.
size_t GetNbObjs ( const GConceptType obj) const

Get the number of concept types.

Parameters
objPseudo-parameter.
size_t GetMaxObjId ( const GConceptType obj) const

Get the highest identifier of the concept types.

Parameters
objPseudo-parameter.
GConceptType* GetObj ( const GConceptType obj,
char  id,
bool  null 
)

Get the a pointer to a type of concept.

Parameters
objPseudo-parameter.
idIdentifier of the type.
nullIf set to true, if the type does not exist, return 0, else an exception is generated.
Returns
Pointer to a GConceptType.
GConceptType* GetObj ( const GConceptType obj,
const R::RString name,
bool  null 
)

Get the a pointer to a type of concept.

Parameters
objPseudo-parameter.
nameName of the type.
nullIf set to true, if the type does not exist, return 0, else an exception is generated.
Returns
Pointer to a GConceptType.
R::RCursor<GConceptType> GetObjs ( const GConceptType obj) const

Get all concept types defined.

Parameters
objPseudo-parameter.
Returns
RCursor over GConceptType.
GConceptType* InsertObj ( const GConceptType obj,
tConceptCat  cat,
size_t  id,
const R::RString name,
const R::RString desc,
bool &  newone 
)

Create a new concept type. If the concept type exists, nothing is done.

Parameters
objPseudo-parameter.
catConcept category.
idIdentifier of the type (if cNoRef, an identifier is assigned).
nameName of the type.
descShort description
newoneIs the concept type a new one (set by the method).
Returns
Pointer to a GConceptType.
GConceptType* InsertObj ( const GConceptType obj,
tConceptCat  cat,
size_t  id,
const R::RString name,
const R::RString desc 
)

Create a new concept type. If the concept type exists, nothing is done.

Parameters
objPseudo-parameter.
catConcept category.
idIdentifier of the type (if cNoRef, an identifier is assigned).
nameName of the type.
descShort description
Returns
Pointer to a GConceptType.
GConceptType* InsertObj ( const GConceptType obj,
tConceptCat  cat,
const R::RString name,
const R::RString desc,
bool &  newone 
)

Create a new concept type. If the concept type exists, nothing is done.

Parameters
objPseudo-parameter.
catConcept category.
nameName of the type.
descShort description
newoneIs the concept type a new one (set by the method).
Returns
Pointer to a GConceptType.
GConceptType* InsertObj ( const GConceptType obj,
tConceptCat  cat,
const R::RString name,
const R::RString desc 
)

Create a new concept type. If the concept type exists, nothing is done.

Parameters
objPseudo-parameter.
catConcept category.
idIdentifier of the type (if cNoRef, an identifier is assigned).
nameName of the type.
descShort description
Returns
Pointer to a GConceptType.
size_t GetNbObjs ( const GConcept obj) const

Get the number of concepts.

Parameters
objPseudo-parameter.
size_t GetMaxObjId ( const GConcept obj) const

Get the highest identifier of the concepts.

Parameters
objPseudo-parameter.
R::RCursor<GConcept> GetObjs ( const GConcept obj) const

Get all concept defined.

Parameters
objPseudo-parameter.
Returns
RCursor over GConcept.
GConcept* GetObj ( const GConcept obj,
size_t  id 
)

Get the concept with a specific identifier.

Parameters
idIdentifier.
Returns
a pointer to a GConcept.
GConcept* GetObj ( const GConcept obj,
GConceptType type,
const R::RString concept,
bool  null = false 
)

Get a pointer to a concept.

Parameters
objPseudo-parameter.
typeType of the concept.
conceptName of the concept to insert.
nullIf set to true, if the object does not exist, return 0, else an exception is generated.
GConcept* InsertObj ( const GConcept obj,
GConceptType type,
const R::RString concept,
bool &  newone 
)

Insert a concept of a given type and name. If the concept already exists, nothing is done.

Parameters
objPseudo-parameter.
typeType of the concept.
conceptName of the concept to insert.
newoneIs the concept type a new one (set by the method).
Returns
a pointer to the concept is the dictionary.
GConcept* InsertObj ( const GConcept obj,
GConceptType type,
const R::RString concept 
)

Insert a concept of a given type and name. If the concept already exists, nothing is done.

Parameters
objPseudo-parameter.
typeType of the concept.
conceptName of the concept to insert.
Returns
a pointer to the concept is the dictionary.
GConcept* InsertObj ( const GConcept concept,
bool &  newone 
)

Insert a concept that is exactly the same as a model. If the concept exist, nothing is done.

Parameters
conceptModel Concept.
newoneIs the concept type a new one (set by the method).
Returns
a pointer to the concept is the dictionary.
GConcept* InsertObj ( const GConcept concept)

Insert a concept that is exactly the same as a model. If the concept exist, nothing is done.

Parameters
conceptModel Concept.
Returns
a pointer to the concept is the dictionary.
GConcept* RenameObj ( GConcept concept,
const R::RString name 
)

Rename a concept.

Parameters
conceptConcept to rename.
nameNew name.
Returns
a pointer to the correct concept (may be an existing one).
void DeleteObj ( GConcept concept)

Delete a given concept from the dictionary.

Parameters
conceptConcept to delete.
GStatement* GetObj ( const GStatement obj,
size_t  id,
bool  null = false 
)

Get a statement.

Parameters
objPseudo-parameter.
idIdentifier of the statement.
nullCan a null pointer be returned or an exception must be generated.
Returns
Pointer to a statement.
GStatement* GetObj ( const GStatement obj,
GObject subject,
GObject predicate,
GObject value,
bool  null = false 
)

Get a statement.

Parameters
objPseudo-parameter.
subjectSubject.
predicatePredicate.
valueValue.
nullCan a null pointer be returned or an exception must be generated.
Returns
a pointer to the newly statement created or the existing one.
GStatement* InsertObj ( const GStatement obj,
size_t  id,
GObject subject,
GObject predicate,
GObject value,
double  weight,
bool &  newone 
)

Insert a new statement. If it exists, it is not re-created but its weight is updated.

Parameters
objPseudo-parameter.
idIdentifier of the statement. If cNoRef, an identifier is assigned.
subjectSubject.
predicatePredicate.
valueValue.
weightWeight of the statement.
newoneIs the concept type a new one (set by the method).
Returns
a pointer to the newly statement created or the existing one.
GStatement* InsertObj ( const GStatement obj,
size_t  id,
GObject subject,
GObject predicate,
GObject value,
double  weight 
)

Insert a new statement. If it exists, it is not re-created but its weight is updated.

Parameters
objPseudo-parameter.
idIdentifier of the statement. If cNoRef, an identifier is assigned.
subjectSubject.
predicatePredicate.
valueValue.
weightWeight of the statement.
Returns
a pointer to the newly statement created or the existing one.

Member Data Documentation

GSession* Session
protected

Session.

tObjState State
protected

State of the knowledge base.

GStorage* Storage
protected

Storage manager.

bool SaveResults
protected

Must the results be saved after computed ?

GConceptType* TokenType
protected

Default type for tokens.

GConceptType* DCMIType
protected

Default type for the Dublin Core Metadata Initiative.

GConceptType* NamedEntityType
protected

Default type for named entities.

GConceptType* URIType
protected

Default type for URI.

GConceptType* TaxonomyType
protected

Concept type that represents relations of taxonomies.

GConcept* Content
protected

Meta-concept representing the content of a document.

GConcept* NamedEntity
protected

Concepts related to named entities.

GConcept* URI
protected

Concepts related to the default URI content.

GConcept* IsA
protected

Concept that represents a "IsA" relation.

GConcept* Synonym
protected

Concept that represents a "synonym" relation.

GConcept* PartOf
protected

Concept that represents a "part of" relation.

GConcept* Unknown
protected

"Unknown" concept.

R::RObjectContainer<GConceptType,true> ConceptTypes
protected

Types of Concepts.

R::RObjectHashContainer<GConcept,true> Concepts
protected

Concepts.

R::RContainer<GStatement,true,false> StatementsByIds
protected

Statements (accessed by identifier).