String<->Id bijection storage. More...
Public Types | |
typedef std::shared_ptr< Vocabulary > | ptr |
Public Member Functions | |
Vocabulary () | |
void | add (const std::string &token) |
add new token to vocabulary, ID is auto-generated More... | |
int | getId (const std::string &token) const |
get the ID of the token More... | |
std::string | getToken (int id) const |
get token by ID More... | |
int | getSize () const |
get the number of elements in the vocabulary More... | |
int | getStartSequenceId () override |
int | getEndSequenceId () override |
Private Attributes | |
std::map< std::string, int > | mTokenToId |
std::vector< std::string > | mIdToToken |
int | mNumTokens |
int | mSosId |
int | mEosId |
int | mUnkId |
Static Private Attributes | |
static const std::string | mSosStr = "<s>" |
static const std::string | mUnkStr = "<unk>" |
static const std::string | mEosStr = "</s>" |
Friends | |
std::istream & | operator>> (std::istream &input, Vocabulary &value) |
String<->Id bijection storage.
typedef std::shared_ptr<Vocabulary> nmtSample::Vocabulary::ptr |
nmtSample::Vocabulary::Vocabulary | ( | ) |
void nmtSample::Vocabulary::add | ( | const std::string & | token | ) |
add new token to vocabulary, ID is auto-generated
int nmtSample::Vocabulary::getId | ( | const std::string & | token | ) | const |
get the ID of the token
std::string nmtSample::Vocabulary::getToken | ( | int | id | ) | const |
get token by ID
int nmtSample::Vocabulary::getSize | ( | ) | const |
get the number of elements in the vocabulary
|
overridevirtual |
Implements nmtSample::SequenceProperties.
|
overridevirtual |
Implements nmtSample::SequenceProperties.
|
friend |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |