57#ifndef DOXYGEN_SHOULD_SKIP_THIS
72 return this->
back_dico_.second(translated_val.discr_val);
73 }
catch (Exception
const&) {
75 if (translated_val.discr_val == std::numeric_limits< std::size_t >::max()) {
76 if (!_nonint_missing_symbol_.empty())
return _nonint_missing_symbol_;
81 "The back translation of \"" << translated_val.discr_val
82 <<
"\" could not be found");
89 const auto& labels = _variable_.labels();
90 const std::size_t size = labels.size();
91 std::vector< std::pair< std::size_t, std::string > > xlabels;
92 xlabels.reserve(size);
93 bool modifications =
false;
94 for (std::size_t i = std::size_t(0); i < size; ++i) {
95 const std::size_t old_val = this->
back_dico_.first(labels[i]);
96 xlabels.push_back(std::make_pair(old_val, labels[i]));
97 if (old_val != i) modifications =
true;
102 if (!modifications) {
return HashTable< std::size_t, std::size_t >(); }
107 HashTable< std::size_t, std::size_t > mapping((
Size)size);
108 for (std::size_t i = std::size_t(0); i < size; ++i) {
109 mapping.insert(xlabels[i].first, i);
110 this->
back_dico_.insert(i, xlabels[i].second);
118 return _variable_.domainSize();
126 return DBTranslatedValue{std::numeric_limits< std::size_t >::max()};
The class representing the original values of the cells of databases.
The databases' cell translators for range variables.
virtual const RangeVariable * variable() const final
returns the variable stored into the translator
DBTranslator4RangeVariable(const std::vector< std::string > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor without any initial variable
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
virtual std::size_t domainSize() const final
returns the domain size of a variable corresponding to the translations
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
virtual HashTable< std::size_t, std::size_t > reorder() final
performs a reordering of the dictionary and returns a mapping from the old translated values to the n...
virtual ~DBTranslator4RangeVariable()
destructor
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
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
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.