LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Lima::Common::BagOfWords::BoWToken Class Reference

This class contains the representation of an element of the bag of words. More...

#include <linguisticProcessing/common/BagOfWords/bowToken.h>

Inheritance diagram for Lima::Common::BagOfWords::BoWToken:
Lima::Common::BagOfWords::AbstractBoWElement Lima::Common::BagOfWords::BoWComplexToken Lima::Common::BagOfWords::BoWNamedEntity Lima::Common::BagOfWords::BoWTerm

Public Member Functions

 BoWToken (const Lima::LimaString &lemma, const LinguisticCode category, const uint64_t position, const uint64_t length)
 
 BoWToken (const Lima::LimaString &str, const uint64_t position=0, const uint64_t length=0)
 
 BoWToken (const BoWToken &tok)
 
 BoWToken ()
 
virtual ~BoWToken ()
 
virtual void clear () override
 
virtual BoWToken * clone () const override
 
virtual Lima::LimaString getLemma (void) const
 
virtual Lima::LimaString getInflectedForm (void) const
 
LinguisticCode getCategory (void) const
 
uint64_t getPosition (void) const override
 
uint64_t getLength (void) const override
 
virtual uint64_t size (void) const override
 size of the BoWToken is the number of parts in the token
 
void setLemma (const Lima::LimaString &lemma)
 
void setInflectedForm (const Lima::LimaString &inflectedForm)
 
void setCategory (LinguisticCode c)
 
void setPosition (const uint64_t pos) override
 
void setLength (const uint64_t len) override
 
virtual Lima::LimaString getString (void) const override
 
virtual BoWType getType () const override
 
uint64_t getVertex () const
 
void setVertex (uint64_t vertex)
 
virtual std::set< uint64_t > getVertices () const override
 returns a singleton made of the value of the getVertex function.
 
virtual std::string getOutputUTF8String (const Common::PropertyCode::PropertyManager *macroManager=0) const override
 get a string of the BoWToken for output function
 
virtual std::string getIdUTF8String () const override
 function used to identify a bowtoken in a text (used in BowDumper)
 
bool operator== (const BoWToken &) const
 redefine equality
 
bool operator!= (const BoWToken &) const
 redefine inequality as negation of equality.
 
virtual Common::Misc::PositionLengthList getPositionLengthList () const
 get the list of (position,length) couples of the elements of the token (if several)
 
virtual void addToPosition (const uint64_t offset)
 add the offset to the position of the token
 
- Public Member Functions inherited from Lima::Common::BagOfWords::AbstractBoWElement
 AbstractBoWElement ()
 
virtual ~AbstractBoWElement ()
 

Static Public Member Functions

static void setInternalSeparator (const LimaChar c)
 
static void setCompoundSeparator (const LimaChar c)
 
static LimaChar getInternalSeparator ()
 
static LimaChar getCompoundSeparator ()
 
static void setUseOnlyLemma (const bool b)
 
static bool getUseOnlyLemma ()
 

Protected Member Functions

 BoWToken (BoWTokenPrivate &d)
 
BoWToken & operator= (const BoWToken &tok)
 
bool operator== (const BoWToken &tok)
 

Protected Attributes

BoWTokenPrivate * m_d
 

Friends

class BoWTokenPrivate
 
LIMA_BOW_EXPORT std::ostream & operator<< (std::ostream &, const BoWToken &)
 
LIMA_BOW_EXPORT QDebug & operator<< (QDebug &, const BoWToken &)
 
LIMA_BOW_EXPORT std::ostream & operator<< (std::ostream &os, const Common::Misc::PositionLengthList &p)
 
LIMA_BOW_EXPORT QDebug & operator<< (QDebug &os, const Common::Misc::PositionLengthList &p)
 
LIMA_BOW_EXPORT std::ostream & operator<< (std::ostream &os, const std::map< BoWToken *, uint64_t > &refMap)
 only for debug
 
LIMA_BOW_EXPORT QDebug & operator<< (QDebug &os, const std::map< BoWToken *, uint64_t > &refMap)
 

Detailed Description

This class contains the representation of an element of the bag of words.

This element is characterized by a normalized form, a grammatical category, its position and length. It can be a simple word, a multiterm or a named entity.

Definition at line 45 of file bowToken.h.

Constructor & Destructor Documentation

◆ BoWToken() [1/5]

Lima::Common::BagOfWords::BoWToken::BoWToken ( const Lima::LimaString &  lemma,
const LinguisticCode  category,
const uint64_t  position,
const uint64_t  length 
)

◆ BoWToken() [2/5]

Lima::Common::BagOfWords::BoWToken::BoWToken ( const Lima::LimaString &  str,
const uint64_t  position = 0,
const uint64_t  length = 0 
)

◆ BoWToken() [3/5]

Lima::Common::BagOfWords::BoWToken::BoWToken ( const BoWToken &  tok)

Definition at line 204 of file bowToken.cpp.

◆ BoWToken() [4/5]

Lima::Common::BagOfWords::BoWToken::BoWToken ( )

Definition at line 182 of file bowToken.cpp.

◆ ~BoWToken()

Lima::Common::BagOfWords::BoWToken::~BoWToken ( )
virtual

Definition at line 274 of file bowToken.cpp.

◆ BoWToken() [5/5]

Lima::Common::BagOfWords::BoWToken::BoWToken ( BoWTokenPrivate &  d)
protected

Definition at line 173 of file bowToken.cpp.

Member Function Documentation

◆ addToPosition()

void Lima::Common::BagOfWords::BoWToken::addToPosition ( const uint64_t  offset)
virtual

add the offset to the position of the token

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 326 of file bowToken.cpp.

◆ clear()

virtual void Lima::Common::BagOfWords::BoWToken::clear ( )
inlineoverridevirtual

Reimplemented from Lima::Common::BagOfWords::AbstractBoWElement.

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 62 of file bowToken.h.

◆ clone()

BoWToken * Lima::Common::BagOfWords::BoWToken::clone ( ) const
overridevirtual

◆ getCategory()

LinguisticCode Lima::Common::BagOfWords::BoWToken::getCategory ( void  ) const

Definition at line 285 of file bowToken.cpp.

◆ getCompoundSeparator()

LimaChar Lima::Common::BagOfWords::BoWToken::getCompoundSeparator ( )
static

Definition at line 321 of file bowToken.cpp.

◆ getIdUTF8String()

std::string Lima::Common::BagOfWords::BoWToken::getIdUTF8String ( void  ) const
overridevirtual

function used to identify a bowtoken in a text (used in BowDumper)

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Reimplemented in Lima::Common::BagOfWords::BoWNamedEntity, and Lima::Common::BagOfWords::BoWTerm.

Definition at line 446 of file bowToken.cpp.

◆ getInflectedForm()

Lima::LimaString Lima::Common::BagOfWords::BoWToken::getInflectedForm ( void  ) const
virtual

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 284 of file bowToken.cpp.

◆ getInternalSeparator()

LimaChar Lima::Common::BagOfWords::BoWToken::getInternalSeparator ( )
static

Definition at line 317 of file bowToken.cpp.

◆ getLemma()

Lima::LimaString Lima::Common::BagOfWords::BoWToken::getLemma ( void  ) const
virtual

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 283 of file bowToken.cpp.

◆ getLength()

uint64_t Lima::Common::BagOfWords::BoWToken::getLength ( void  ) const
overridevirtual

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Definition at line 287 of file bowToken.cpp.

◆ getOutputUTF8String()

std::string Lima::Common::BagOfWords::BoWToken::getOutputUTF8String ( const Common::PropertyCode::PropertyManager *  macroManager = 0) const
overridevirtual

get a string of the BoWToken for output function

Parameters
macroAccessorif not null, will output the human readable form of the macrocategory. otherwise output the integer code

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Reimplemented in Lima::Common::BagOfWords::BoWNamedEntity, and Lima::Common::BagOfWords::BoWTerm.

Definition at line 430 of file bowToken.cpp.

◆ getPosition()

uint64_t Lima::Common::BagOfWords::BoWToken::getPosition ( void  ) const
overridevirtual

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Definition at line 286 of file bowToken.cpp.

◆ getPositionLengthList()

Common::Misc::PositionLengthList Lima::Common::BagOfWords::BoWToken::getPositionLengthList ( ) const
virtual

get the list of (position,length) couples of the elements of the token (if several)

Returns

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 382 of file bowToken.cpp.

◆ getString()

LimaString Lima::Common::BagOfWords::BoWToken::getString ( void  ) const
overridevirtual

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Definition at line 332 of file bowToken.cpp.

◆ getType()

BoWType Lima::Common::BagOfWords::BoWToken::getType ( ) const
overridevirtual

◆ getUseOnlyLemma()

bool Lima::Common::BagOfWords::BoWToken::getUseOnlyLemma ( )
static

Definition at line 305 of file bowToken.cpp.

◆ getVertex()

uint64_t Lima::Common::BagOfWords::BoWToken::getVertex ( ) const

Definition at line 301 of file bowToken.cpp.

◆ getVertices()

std::set< uint64_t > Lima::Common::BagOfWords::BoWToken::getVertices ( ) const
overridevirtual

returns a singleton made of the value of the getVertex function.

Subclasses like BoWComplexToken reimplement this method to return the set of vertices of all their parts.

Returns
a singleton made of the value of the getVertex function

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken, and Lima::Common::BagOfWords::BoWNamedEntity.

Definition at line 454 of file bowToken.cpp.

◆ operator!=()

bool Lima::Common::BagOfWords::BoWToken::operator!= ( const BoWToken &  t) const

redefine inequality as negation of equality.

Author
Benoit Mathieu

Definition at line 407 of file bowToken.cpp.

◆ operator=()

BoWToken & Lima::Common::BagOfWords::BoWToken::operator= ( const BoWToken &  tok)
protected

Definition at line 213 of file bowToken.cpp.

◆ operator==() [1/2]

bool Lima::Common::BagOfWords::BoWToken::operator== ( const BoWToken &  t) const

redefine equality

Author
Benoit Mathieu return true if :
  • objects have the same BowType
  • objects have the same category
  • objects have the same lemma
  • if objects are of BoWNamedEntity type, objects have the same NamedEntityType.

Definition at line 394 of file bowToken.cpp.

◆ operator==() [2/2]

bool Lima::Common::BagOfWords::BoWToken::operator== ( const BoWToken &  tok)
protected

Definition at line 223 of file bowToken.cpp.

◆ setCategory()

void Lima::Common::BagOfWords::BoWToken::setCategory ( LinguisticCode  c)

Definition at line 295 of file bowToken.cpp.

◆ setCompoundSeparator()

void Lima::Common::BagOfWords::BoWToken::setCompoundSeparator ( const LimaChar  c)
static

Definition at line 312 of file bowToken.cpp.

◆ setInflectedForm()

void Lima::Common::BagOfWords::BoWToken::setInflectedForm ( const Lima::LimaString &  inflectedForm)

Definition at line 293 of file bowToken.cpp.

◆ setInternalSeparator()

void Lima::Common::BagOfWords::BoWToken::setInternalSeparator ( const LimaChar  c)
static

Definition at line 308 of file bowToken.cpp.

◆ setLemma()

void Lima::Common::BagOfWords::BoWToken::setLemma ( const Lima::LimaString &  lemma)

Definition at line 292 of file bowToken.cpp.

◆ setLength()

void Lima::Common::BagOfWords::BoWToken::setLength ( const uint64_t  len)
overridevirtual

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Definition at line 297 of file bowToken.cpp.

◆ setPosition()

void Lima::Common::BagOfWords::BoWToken::setPosition ( const uint64_t  pos)
overridevirtual

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Definition at line 296 of file bowToken.cpp.

◆ setUseOnlyLemma()

void Lima::Common::BagOfWords::BoWToken::setUseOnlyLemma ( const bool  b)
static

Definition at line 304 of file bowToken.cpp.

◆ setVertex()

void Lima::Common::BagOfWords::BoWToken::setVertex ( uint64_t  vertex)

Definition at line 302 of file bowToken.cpp.

◆ size()

uint64_t Lima::Common::BagOfWords::BoWToken::size ( void  ) const
overridevirtual

size of the BoWToken is the number of parts in the token

Implements Lima::Common::BagOfWords::AbstractBoWElement.

Reimplemented in Lima::Common::BagOfWords::BoWComplexToken.

Definition at line 290 of file bowToken.cpp.

Friends And Related Symbol Documentation

◆ BoWTokenPrivate

friend class BoWTokenPrivate
friend

Definition at line 47 of file bowToken.h.

◆ operator<< [1/6]

LIMA_BOW_EXPORT QDebug & operator<< ( QDebug &  os,
const BoWToken &  tok 
)
friend

Definition at line 423 of file bowToken.cpp.

◆ operator<< [2/6]

LIMA_BOW_EXPORT QDebug & operator<< ( QDebug &  os,
const Common::Misc::PositionLengthList &  p 
)
friend

Definition at line 56 of file positionLengthList.cpp.

◆ operator<< [3/6]

LIMA_BOW_EXPORT QDebug & operator<< ( QDebug &  os,
const std::map< BoWToken *, uint64_t > &  refMap 
)
friend

◆ operator<< [4/6]

LIMA_BOW_EXPORT std::ostream & operator<< ( std::ostream &  os,
const BoWToken &  tok 
)
friend

Definition at line 416 of file bowToken.cpp.

◆ operator<< [5/6]

LIMA_BOW_EXPORT std::ostream & operator<< ( std::ostream &  os,
const Common::Misc::PositionLengthList &  p 
)
friend

Definition at line 39 of file positionLengthList.cpp.

◆ operator<< [6/6]

LIMA_BOW_EXPORT std::ostream & operator<< ( std::ostream &  os,
const std::map< BoWToken *, uint64_t > &  refMap 
)
friend

only for debug

Member Data Documentation

◆ m_d

BoWTokenPrivate* Lima::Common::BagOfWords::BoWToken::m_d
protected

Definition at line 166 of file bowToken.h.


The documentation for this class was generated from the following files: