36 #ifndef GUM_LEARNING_DB_TRANSLATOR_SET_H 37 #define GUM_LEARNING_DB_TRANSLATOR_SET_H 41 #include <type_traits> 43 #include <agrum/agrum.h> 44 #include <agrum/tools/database/DBTranslator.h> 45 #include <agrum/tools/database/DBTranslator4LabelizedVariable.h> 46 #include <agrum/tools/database/DBTranslator4DiscretizedVariable.h> 47 #include <agrum/tools/database/DBTranslator4RangeVariable.h> 48 #include <agrum/tools/database/DBTranslator4ContinuousVariable.h> 113 template <
template <
typename >
class ALLOC = std::allocator >
133 const allocator_type& alloc);
140 const allocator_type& alloc);
197 template <
template <
template <
typename >
class >
class Translator >
199 const std::size_t column,
200 const bool unique_column =
true);
216 template <
template <
typename >
class XALLOC >
219 const std::size_t column,
236 const std::size_t column,
237 const bool unique_column =
true);
253 void eraseTranslator(
const std::size_t k,
const bool k_is_input_col =
false);
287 template <
template <
typename >
class OTHER_ALLOC >
303 template <
template <
typename >
class OTHER_ALLOC >
348 const std::size_t k)
const;
360 const std::size_t k)
const;
366 std::size_t
domainSize(
const std::size_t k)
const;
446 std::size_t
inputColumn(
const std::size_t k)
const;
464 std::size_t
size()
const;
475 #ifndef DOXYGEN_SHOULD_SKIP_THIS 484 std::vector< std::size_t, ALLOC< std::size_t > > columns__;
487 std::size_t highest_column__{std::size_t(0)};
490 void copy__(
const DBTranslatorSet< ALLOC >& from,
491 const allocator_type& alloc);
501 #include <agrum/tools/database/DBTranslatorSet_tpl.h> HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder(const std::size_t k)
performs a reordering of the dictionary and returns a mapping from the old translated values to the n...
const Variable & variable(const std::size_t k) const
returns the variable stored into the kth translator
DBTranslatorSet(const DBTranslatorSet< ALLOC > &from, const allocator_type &alloc)
copy constructor with a given allocator
const std::vector< DBTranslator< ALLOC > *, ALLOC< DBTranslator< ALLOC > *> > & translators() const
returns the set of translators
void eraseTranslator(const std::size_t k, const bool k_is_input_col=false)
erases either the kth translator or those parsing the kth column of the input database ...
DBTranslatorSet(const DBTranslatorSet< ALLOC > &from)
copy constructor
DBTranslatorSet< ALLOC > & operator=(const DBTranslatorSet< ALLOC > &from)
copy operator
std::string translateBack(const DBTranslatedValue translated_val, const std::size_t k) const
returns the original string that was translated into translated_val
const Variable & variableSafe(const std::size_t k) const
returns the variable stored into the kth translator
std::size_t domainSizeSafe(const std::size_t k) const
returns the domain size of the variable stored into the kth translator
INLINE void emplace(Args &&... args)
std::size_t highestInputColumn() const
returns the largest input database column index read by the translators
DBTranslator< ALLOC > & translatorSafe(const std::size_t k)
returns the kth translator
std::size_t insertTranslator(const Variable &var, const std::size_t column, const bool unique_column=true)
inserts a new translator for a given variable at the end of the translator set
const DBTranslator< ALLOC > & operator[](const std::size_t k) const
returns the kth translator
std::size_t inputColumnSafe(const std::size_t k) const
returns the column of the input database that will be read by the kth translator
DBTranslatorSet(DBTranslatorSet< ALLOC > &&from, const allocator_type &alloc)
move constructor with a given allocator
std::size_t nbTranslators() const
returns the number of translators stored into the set
DBTranslator< ALLOC > & operator[](const std::size_t k)
returns the kth translator
std::size_t domainSize(const std::size_t k) const
returns the domain size of the variable stored into the kth translator
std::size_t insertTranslator(const Variable &var, const std::size_t column, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool unique_column=true)
inserts a new translator for a given variable at the end of the translator set
DBTranslator< ALLOC > & translator(const std::size_t k)
returns the kth translator
bool isMissingValueSafe(const DBTranslatedValue translated_val, const std::size_t k) const
similar to method isMissingValue, except that it checks that the kth translator exists ...
allocator_type getAllocator() const
returns the allocator used by the translator set
std::size_t insertTranslator(const Translator< ALLOC > &translator, const std::size_t column, const bool unique_column=true)
inserts a new translator at the end of the translator set
bool needsReordering(const std::size_t k) const
indicates whether a reordering is needed to make the kth translator sorted
virtual ~DBTranslatorSet()
destructor
std::size_t inputColumn(const std::size_t k) const
returns the column of the input database that will be read by the kth translator
const DBTranslator< ALLOC > & translator(const std::size_t k) const
returns the kth translator
std::string translateBackSafe(const DBTranslatedValue translated_val, const std::size_t k) const
similar to method translateBack, except that it checks that the kth translator exists ...
const DBTranslator< ALLOC > & translatorSafe(const std::size_t k) const
returns the kth translator
std::size_t size() const
returns the number of translators stored into the set
DBTranslatorSet< ALLOC > & operator=(DBTranslatorSet< ALLOC > &&from)
move operator
DBTranslatedValue translateSafe(const std::vector< std::string, OTHER_ALLOC< std::string > > &row, const std::size_t k) const
similar to method translate, except that it checks that the kth translator exists ...
bool needsReorderingSafe(const std::size_t k) const
same as method needsReordering but checks that the kth translator exists
DBTranslatedValue translate(const std::vector< std::string, OTHER_ALLOC< std::string > > &row, const std::size_t k) const
ask the kth translator to translate a string in a row of the database
void clear()
remove all the translators
HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorderSafe(const std::size_t k)
same as method reorder but checks that the kth translator exists
virtual DBTranslatorSet< ALLOC > * clone() const
virtual copy constructor
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
virtual DBTranslatorSet< ALLOC > * clone(const allocator_type &alloc) const
virtual copy constructor with a given allocator
bool isMissingValue(const DBTranslatedValue translated_val, const std::size_t k) const
indicates whether the kth translator considers a translated_val as a missing value ...
DBTranslatorSet(DBTranslatorSet< ALLOC > &&from)
move constructor