TRF Language Model
trf::Vocab Class Reference

#include <trf-vocab.h>

Public Member Functions

 Vocab ()
 
 Vocab (const char *pathVocab)
 
 ~Vocab ()
 
int GetSize ()
 get the vocab size, i.e. the word number More...
 
int GetClassNum ()
 get the total class number More...
 
const char * GetWordStr (int id)
 get word string More...
 
VocabIDGetClassMap ()
 get class map More...
 
VocabID GetClass (VocabID wid)
 get class More...
 
void GetClass (VocabID *pcid, const VocabID *pwid, int nlen)
 get classes of a word sequence More...
 
VocabID RandClass ()
 random a class More...
 
Array< int > * GetWord (VocabID cid)
 get word belonging to a class More...
 
int IterBeg () const
 iter all the words, regardless the beg/end symbols More...
 
int IterEnd () const
 iter all the words, regardless the beg/end symbols More...
 
bool IsLegalWord (VocabID id) const
 Check if the VocabID is a legal word. More...
 

Public Attributes

Array< VocabIDm_aWordID
 the word id. i.e 0,1,2,3,... More...
 
Array< Stringm_aWords
 the string of each vocabulary id More...
 
Array< VocabIDm_aClass
 store the classes of each word. Support soft and hard class More...
 
Array< Array< VocabID > * > m_aClass2Word
 store the word belonging to each class. More...
 

Detailed Description

Definition at line 34 of file trf-vocab.h.

Constructor & Destructor Documentation

§ Vocab() [1/2]

trf::Vocab::Vocab ( )

Definition at line 22 of file trf-vocab.cpp.

§ Vocab() [2/2]

trf::Vocab::Vocab ( const char *  pathVocab)

Definition at line 28 of file trf-vocab.cpp.

§ ~Vocab()

trf::Vocab::~Vocab ( )

Definition at line 110 of file trf-vocab.cpp.

Member Function Documentation

§ GetClass() [1/2]

VocabID trf::Vocab::GetClass ( VocabID  wid)
inline

get class

Definition at line 62 of file trf-vocab.h.

§ GetClass() [2/2]

void trf::Vocab::GetClass ( VocabID pcid,
const VocabID pwid,
int  nlen 
)

get classes of a word sequence

Definition at line 118 of file trf-vocab.cpp.

§ GetClassMap()

VocabID* trf::Vocab::GetClassMap ( )
inline

get class map

Definition at line 60 of file trf-vocab.h.

§ GetClassNum()

int trf::Vocab::GetClassNum ( )
inline

get the total class number

Definition at line 49 of file trf-vocab.h.

§ GetSize()

int trf::Vocab::GetSize ( )
inline

get the vocab size, i.e. the word number

Definition at line 47 of file trf-vocab.h.

§ GetWord()

Array<int>* trf::Vocab::GetWord ( VocabID  cid)
inline

get word belonging to a class

Definition at line 76 of file trf-vocab.h.

§ GetWordStr()

const char* trf::Vocab::GetWordStr ( int  id)
inline

get word string

Definition at line 51 of file trf-vocab.h.

§ IsLegalWord()

bool trf::Vocab::IsLegalWord ( VocabID  id) const
inline

Check if the VocabID is a legal word.

Definition at line 86 of file trf-vocab.h.

§ IterBeg()

int trf::Vocab::IterBeg ( ) const
inline

iter all the words, regardless the beg/end symbols

Definition at line 82 of file trf-vocab.h.

§ IterEnd()

int trf::Vocab::IterEnd ( ) const
inline

iter all the words, regardless the beg/end symbols

Definition at line 84 of file trf-vocab.h.

§ RandClass()

VocabID trf::Vocab::RandClass ( )
inline

random a class

Definition at line 70 of file trf-vocab.h.

Member Data Documentation

§ m_aClass

Array<VocabID> trf::Vocab::m_aClass

store the classes of each word. Support soft and hard class

Definition at line 39 of file trf-vocab.h.

§ m_aClass2Word

Array<Array<VocabID>*> trf::Vocab::m_aClass2Word

store the word belonging to each class.

Definition at line 40 of file trf-vocab.h.

§ m_aWordID

Array<VocabID> trf::Vocab::m_aWordID

the word id. i.e 0,1,2,3,...

Definition at line 37 of file trf-vocab.h.

§ m_aWords

Array<String> trf::Vocab::m_aWords

the string of each vocabulary id

Definition at line 38 of file trf-vocab.h.


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