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

This class provides a dictionary interface for the purpose of string encoding. More...

#include <string_encoding_dictionary.hpp>

Public Types

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

Public Member Functions

bool HasToken (const Token &token) const
 The function returns true if the dictionary contains the given token. More...
 
template<typename T >
size_t AddToken (T &&token)
 The function adds the given token to the dictionary and assigns a label to the token. More...
 
size_t Value (const Token &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.
 

Detailed Description

template<typename Token>
class mlpack::data::StringEncodingDictionary< Token >

This class provides a dictionary interface for the purpose of string encoding.

It works like an adapter to the internal dictionary.

Template Parameters
TokenType of the token that the dictionary stores.

Member Function Documentation

◆ AddToken()

template<typename Token >
template<typename T >
size_t mlpack::data::StringEncodingDictionary< Token >::AddToken ( T &&  token)
inline

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()

template<typename Token >
bool mlpack::data::StringEncodingDictionary< Token >::HasToken ( const Token &  token) const
inline

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

Parameters
tokenThe given token.

◆ Value()

template<typename Token >
size_t mlpack::data::StringEncodingDictionary< Token >::Value ( const Token &  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: