aGrUM  0.16.0
DBTranslator4RangeVariable.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_DB_TRANSLATOR_4_RANGE_VARIABLE_H
29 #define GUM_LEARNING_DB_TRANSLATOR_4_RANGE_VARIABLE_H
30 
31 #include <agrum/agrum.h>
32 #include <agrum/core/hashTable.h>
33 #include <agrum/core/set.h>
36 
37 
38 namespace gum {
39 
40  namespace learning {
41 
42 
132  template < template < typename > class ALLOC = std::allocator >
133  class DBTranslator4RangeVariable : public DBTranslator< ALLOC > {
134  public:
137 
138 
139  // ##########################################################################
141  // ##########################################################################
142 
144 
146 
159  template < template < typename > class XALLOC >
161  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
162  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
163  const allocator_type& alloc = allocator_type());
164 
166 
178  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
179  const allocator_type& alloc = allocator_type());
180 
182 
201  template < template < typename > class XALLOC >
203  const RangeVariable& var,
204  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
205  const bool editable_dictionary = false,
206  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
207  const allocator_type& alloc = allocator_type());
208 
230  const RangeVariable& var,
231  const bool editable_dictionary = false,
232  std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
233  const allocator_type& alloc = allocator_type());
234 
237 
240  const allocator_type& alloc);
241 
244 
247  const allocator_type& alloc);
248 
251 
254  clone(const allocator_type& alloc) const;
255 
257  virtual ~DBTranslator4RangeVariable();
258 
260 
261 
262  // ##########################################################################
264  // ##########################################################################
265 
267 
271 
275 
277 
278 
279  // ##########################################################################
281  // ##########################################################################
282 
284 
286 
326  virtual DBTranslatedValue translate(const std::string& str) final;
327 
329 
332  virtual std::string
333  translateBack(const DBTranslatedValue translated_val) const final;
334 
336 
337  virtual std::size_t domainSize() const final;
338 
354  virtual bool needsReordering() const final;
355 
364  virtual HashTable< std::size_t,
365  std::size_t,
366  ALLOC< std::pair< std::size_t, std::size_t > > >
367  reorder() final;
368 
370  virtual const RangeVariable* variable() const final;
371 
373  virtual DBTranslatedValue missingValue() const final;
374 
376 
377 
378 #ifndef DOXYGEN_SHOULD_SKIP_THIS
379 
380  private:
381  // the RangeVariable assigned to the translator, if any
382  RangeVariable __variable;
383 
384  // assign to each integer missing symbol a Boolean indicating whether
385  // we already translated it or not. If we translated it, then we cannot
386  // change the range of the variable so that this range contains the symbol.
388  __status_int_missing_symbols;
389 
390  // the set of translations of the integer missing symbols found so far
391  Set< long, ALLOC< long > > __translated_int_missing_symbols;
392 
393  // a string containing a non int missing symbol
394  // (useful for back translations)
395  std::string __nonint_missing_symbol;
396 
397 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
398  };
399 
400 
401  } /* namespace learning */
402 
403 } /* namespace gum */
404 
405 
406 // always include the template implementation
408 
409 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_RANGE_VARIABLE_H */
virtual bool needsReordering() const final
indicates whether a reordering is needed to make the translations sorted by increasing numbers ...
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:120
virtual const RangeVariable * variable() const final
returns the variable stored into the translator
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
STL namespace.
DBTranslator4RangeVariable< ALLOC > & operator=(const DBTranslator4RangeVariable< ALLOC > &from)
copy operator
The databases&#39; cell translators for range variables.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The union class for storing the translated values in learning databases.
The class for generic Hash Tables.
Definition: hashTable.h:679
virtual ~DBTranslator4RangeVariable()
destructor
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:117
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< 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...
Defines a discrete random variable over an integer interval.
Definition: rangeVariable.h:54
virtual std::size_t domainSize() const final
returns the domain size of a variable corresponding to the translations
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
virtual DBTranslator4RangeVariable< ALLOC > * clone() const
virtual copy constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DBTranslator4RangeVariable(const std::vector< std::string, XALLOC< std::string > > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max(), const allocator_type &alloc=allocator_type())
default constructor without any initial variable