mlpack
Public Types | Public Member Functions | List of all members
mlpack::data::StringEncodingDictionary< int > Class Template Reference

Public Types

using MapType = std::array< size_t, 1<< CHAR_BIT >
 A convenient alias for the internal type of the map.
 
using TokenType = int
 The type of the token that the dictionary stores.
 

Public Member Functions

 StringEncodingDictionary ()
 Construct the default class.
 
bool HasToken (const int token) const
 The function returns true if the dictionary contains the given token. More...
 
size_t AddToken (const int token)
 The function adds the given token to the dictionary and assigns a label to the token. More...
 
size_t Value (const int token) const
 The function returns the label assigned to the given token. More...
 
size_t Size () const
 Get the size of the dictionary.
 
void Clear ()
 Clear the dictionary.
 
const MapTypeMapping () const
 Get the mapping.
 
MapTypeMapping ()
 Modify the mapping.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the class to the given archive.
 

Member Function Documentation

◆ AddToken()

size_t mlpack::data::StringEncodingDictionary< int >::AddToken ( const int  token)
inline

The function adds the given token to the dictionary and assigns a label to the token.

The token must belong to [0, 255]; otherwise the behavior is undefined. The label is equal to the resulting size of the dictionary. The function returns the assigned label.

Parameters
tokenThe given token.

◆ HasToken()

bool mlpack::data::StringEncodingDictionary< int >::HasToken ( const int  token) const
inline

The function returns true if the dictionary contains the given token.

The token must belong to [0, 255]; otherwise the behavior is undefined.

Parameters
tokenThe given token.

◆ Value()

size_t mlpack::data::StringEncodingDictionary< int >::Value ( const int  token) const
inline

The function returns the label assigned to the given token.

The function doesn't verify that the dictionary contains the token. The token must belong to [0, 255]; otherwise the behavior is undefined.

Parameters
tokenThe given token.

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