52#ifndef DOXYGEN_SHOULD_SKIP_THIS
78 return DBTranslatedValue{std::numeric_limits< std::size_t >::max()};
82 "String \"" << str <<
"\" cannot be translated because it is not a number");
85 "The translation of \"" << str <<
"\" could not be found for " << _variable_)
92 if (this->
back_dico_.existsFirst(translated_val.discr_val))
93 return this->
back_dico_.second(translated_val.discr_val);
96 if ((translated_val.discr_val == std::numeric_limits< std::size_t >::max())
97 && !this->missing_symbols_.empty()) {
102 "The back translation of \"" << translated_val.discr_val
103 <<
"\" could not be found");
119 return HashTable< std::size_t, std::size_t >();
124 return _variable_.domainSize();
128 INLINE
const NumericalDiscreteVariable*
135 return DBTranslatedValue{std::numeric_limits< std::size_t >::max()};
The databases' cell translators for numerical discrete variables.
DBTranslator4NumericalDiscreteVariable(const NumericalDiscreteVariable &var, const std::vector< std::string > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a numerical discrete variable as translator
bool hasEditableDictionary() const final
indicates that the translator is never in editable dictionary mode
void setEditableDictionaryMode(bool new_mode) final
sets/unset the editable dictionary mode
DBTranslatedValue missingValue() const final
returns the translation of a missing value
std::size_t domainSize() const final
returns the domain size of the variable used for translations
bool needsReordering() const final
indicates that the translations should never be reordered
DBTranslatedValue translate(std::string_view str) final
returns the translation of a string
std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
~DBTranslator4NumericalDiscreteVariable() override
destructor
HashTable< std::size_t, std::size_t > reorder() final
returns an empty HashTable to indicate that no reordering is needed.
const NumericalDiscreteVariable * variable() const final
returns the variable stored into the translator
Bijection< std::size_t, std::string > back_dico_
the bijection relating back translated values and their original strings.
Set< std::string > missing_symbols_
the set of missing symbols
bool isMissingSymbol(std::string_view str) const
indicates whether a string corresponds to a missing symbol
#define GUM_ERROR(type, msg)
std::string compact_tostr(T value)
Returns a path to a unique file name.
bool isNumericalWithResult(std::string_view val, double *res)
return true is a string contains a numerical (double) value
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities
The union class for storing the translated values in learning databases.