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

Public Types

using MapType = std::unordered_map< boost::string_view, size_t, boost::hash< boost::string_view > >
 A convenient alias for the internal type of the map.
 
using TokenType = boost::string_view
 The type of the token that the dictionary stores.
 

Public Member Functions

 StringEncodingDictionary ()=default
 Construct the default class.
 
 StringEncodingDictionary (const StringEncodingDictionary &other)
 Copy the class from the given object.
 
 StringEncodingDictionary (StringEncodingDictionary &&other)=default
 Standard move constructor.
 
StringEncodingDictionaryoperator= (const StringEncodingDictionary &other)
 Copy the class from the given object.
 
StringEncodingDictionaryoperator= (StringEncodingDictionary &&other)=default
 Standard move assignment operator.
 
bool HasToken (const boost::string_view token) const
 The function returns true if the dictionary contains the given token. More...
 
size_t AddToken (const boost::string_view token)
 The function adds the given token to the dictionary and assigns a label to the token. More...
 
size_t Value (const boost::string_view 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 std::deque< std::string > & Tokens () const
 Get the tokens.
 
std::deque< std::string > & Tokens ()
 Modify the tokens.
 
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()

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

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< boost::string_view >::HasToken ( const boost::string_view  token) const
inline

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

Parameters
tokenThe given token.

◆ Value()

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

The function returns the label assigned to the given token.

The function throws std::out_of_range if no such token is found.

Parameters
tokenThe given token.

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