30 #ifndef GUM_LEARNING_DB_TRANSLATOR_H 31 #define GUM_LEARNING_DB_TRANSLATOR_H 38 #include <agrum/agrum.h> 39 #include <agrum/tools/core/bijection.h> 40 #include <agrum/tools/core/set.h> 41 #include <agrum/tools/variables/variable.h> 42 #include <agrum/tools/database/DBTranslatedValue.h> 115 template <
template <
typename >
class ALLOC = std::allocator >
142 template <
template <
typename >
class XALLOC >
144 const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
145 const bool editable_dictionary =
true,
146 std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
163 const bool editable_dictionary =
true,
164 std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
171 DBTranslator(
const DBTranslator< ALLOC >& from,
const allocator_type& alloc);
177 DBTranslator(DBTranslator< ALLOC >&& from,
const allocator_type& alloc);
201 std::string
operator>>(
const DBTranslatedValue translated_val);
264 virtual std::string
translateBack(
const DBTranslatedValue translated_val)
const = 0;
400 #include <agrum/tools/database/DBTranslator_tpl.h> virtual DBTranslator< ALLOC > * clone(const allocator_type &alloc) const =0
virtual copy constructor with a given allocator
DBTranslatedValue operator<<(const std::string &str)
alias for method translate
virtual DBTranslatedValue missingValue() const =0
returns the translation of a missing value
virtual DBTranslatedValue translate(const std::string &str)=0
returns the translation of a string
virtual std::string translateBack(const DBTranslatedValue translated_val) const =0
returns the original value for a given translation
INLINE void emplace(Args &&... args)
std::size_t max_dico_entries_
the maximum number of entries that the dictionary is allowed to contain
void setVariableName(const std::string &str) const
sets the name of the variable stored into the translator
virtual const Variable * variable() const =0
returns the variable stored into the translator
DBTranslator(DBTranslatedValueType val_type, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max(), const allocator_type &alloc=allocator_type())
default constructor
virtual DBTranslator< ALLOC > * clone() const =0
virtual copy constructor
virtual ~DBTranslator()
destructor
virtual bool needsReordering() const =0
indicates whether a reordering is needed to make the translations sorted
const Set< std::string, ALLOC< std::string > > & missingSymbols() const
returns the set of missing symbols taken into account by the translator
DBTranslator(const DBTranslator< ALLOC > &from)
copy constructor
allocator_type getAllocator() const
returns the allocator used by the translator
bool isMissingValue(const DBTranslatedValue &val) const
indicates whether a translated value corresponds to a missing value
DBTranslator(DBTranslator< ALLOC > &&from, const allocator_type &alloc)
move constructor with a given allocator
The base class for all the tabular database cell translators.
DBTranslator< ALLOC > & operator=(const DBTranslator< ALLOC > &from)
copy operator
virtual void setEditableDictionaryMode(bool new_mode)
sets/unset the editable dictionary mode
bool is_dictionary_dynamic_
indicates whether the dictionary can be updated or not
DBTranslatedValueType val_type_
the type of the values translated by the translator
DBTranslator(const DBTranslator< ALLOC > &from, const allocator_type &alloc)
copy constructor with a given allocator
virtual std::size_t domainSize() const =0
returns the domain size of a variable corresponding to the translations
DBTranslator(DBTranslator< ALLOC > &&from)
move constructor
DBTranslator(DBTranslatedValueType val_type, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max(), const allocator_type &alloc=allocator_type())
default constructor without missing symbols
Bijection< std::size_t, std::string, ALLOC< std::pair< float, std::string > > > back_dico_
the bijection relating back translated values and their original strings.
std::string operator>>(const DBTranslatedValue translated_val)
alias for method translateBack
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder()=0
performs a reordering of the dictionary and returns a mapping from the old translated values to the n...
virtual bool hasEditableDictionary() const
indicates whether the translator has an editable dictionary or not
DBTranslator< ALLOC > & operator=(DBTranslator< ALLOC > &&from)
move operator
bool isMissingSymbol(const std::string &str) const
indicates whether a string corresponds to a missing symbol
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
void setVariableDescription(const std::string &str) const
sets the name of the variable stored into the translator
DBTranslatedValueType getValType() const
returns the type of values handled by the translator
Set< std::string, ALLOC< std::string > > missing_symbols_
the set of missing symbols