50#ifndef DOXYGEN_SHOULD_SKIP_THIS
76 return DBTranslatedValue{std::numeric_limits< std::size_t >::max()};
80 "String \"" << str <<
"\" cannot be translated because it is not a number");
83 "The translation of \"" << str <<
"\" could not be found for " << _variable_)
90 if (this->
back_dico_.existsFirst(translated_val.discr_val))
91 return this->
back_dico_.second(translated_val.discr_val);
94 if ((translated_val.discr_val == std::numeric_limits< std::size_t >::max())
95 && !this->missing_symbols_.empty()) {
100 "The back translation of \"" << translated_val.discr_val
101 <<
"\" could not be found");
117 return HashTable< std::size_t, std::size_t >();
122 return _variable_.domainSize();
126 INLINE
const NumericalDiscreteVariable*
133 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
virtual const NumericalDiscreteVariable * variable() const final
returns the variable stored into the translator
virtual bool hasEditableDictionary() const final
indicates that the translator is never in editable dictionary mode
virtual ~DBTranslator4NumericalDiscreteVariable()
destructor
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual std::size_t domainSize() const final
returns the domain size of the variable used for translations
virtual bool needsReordering() const final
indicates that the translations should never be reordered
virtual HashTable< std::size_t, std::size_t > reorder() final
returns an empty HashTable to indicate that no reordering is needed.
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
virtual void setEditableDictionaryMode(bool new_mode) final
sets/unset the editable dictionary mode
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(const std::string &str) const
indicates whether a string corresponds to a missing symbol
#define GUM_ERROR(type, msg)
bool isNumericalWithResult(const std::string &val, double *res)
return true is a string contains a numerical (double) value
std::string compact_tostr(T value)
Returns a path to a unique file name.
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.