TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
nmtSample::Vocabulary Class Reference

String<->Id bijection storage. More...

Inheritance diagram for nmtSample::Vocabulary:
Collaboration diagram for nmtSample::Vocabulary:

Public Types

typedef std::shared_ptr< Vocabularyptr
 

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, intmTokenToId
 
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)
 

Detailed Description

String<->Id bijection storage.

Member Typedef Documentation

◆ ptr

typedef std::shared_ptr<Vocabulary> nmtSample::Vocabulary::ptr

Constructor & Destructor Documentation

◆ Vocabulary()

nmtSample::Vocabulary::Vocabulary ( )

Member Function Documentation

◆ add()

void nmtSample::Vocabulary::add ( const std::string &  token)

add new token to vocabulary, ID is auto-generated

Here is the caller graph for this function:

◆ getId()

int nmtSample::Vocabulary::getId ( const std::string &  token) const

get the ID of the token

◆ getToken()

std::string nmtSample::Vocabulary::getToken ( int  id) const

get token by ID

◆ getSize()

int nmtSample::Vocabulary::getSize ( ) const

get the number of elements in the vocabulary

◆ getStartSequenceId()

int nmtSample::Vocabulary::getStartSequenceId ( )
overridevirtual

◆ getEndSequenceId()

int nmtSample::Vocabulary::getEndSequenceId ( )
overridevirtual

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  input,
Vocabulary value 
)
friend

Member Data Documentation

◆ mSosStr

const std::string nmtSample::Vocabulary::mSosStr = "<s>"
staticprivate

◆ mUnkStr

const std::string nmtSample::Vocabulary::mUnkStr = "<unk>"
staticprivate

◆ mEosStr

const std::string nmtSample::Vocabulary::mEosStr = "</s>"
staticprivate

◆ mTokenToId

std::map<std::string, int> nmtSample::Vocabulary::mTokenToId
private

◆ mIdToToken

std::vector<std::string> nmtSample::Vocabulary::mIdToToken
private

◆ mNumTokens

int nmtSample::Vocabulary::mNumTokens
private

◆ mSosId

int nmtSample::Vocabulary::mSosId
private

◆ mEosId

int nmtSample::Vocabulary::mEosId
private

◆ mUnkId

int nmtSample::Vocabulary::mUnkId
private

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