aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBTranslator4DiscretizedVariable.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47#ifndef GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H
48#define GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H
49
50#include <agrum/agrum.h>
51
54
55namespace gum {
56
57 namespace learning {
58
59
140 public:
141 // ##########################################################################
143 // ##########################################################################
144
146
148
159 template < typename GUM_SCALAR >
161 const std::vector< std::string >& missing_symbols,
162 std::size_t max_dico_entries
163 = std::numeric_limits< std::size_t >::max());
164
177 template < typename GUM_SCALAR >
179 std::size_t max_dico_entries
180 = std::numeric_limits< std::size_t >::max());
181
183
195 const std::vector< std::string >& missing_symbols,
196 std::size_t max_dico_entries
197 = std::numeric_limits< std::size_t >::max());
198
212 std::size_t max_dico_entries
213 = std::numeric_limits< std::size_t >::max());
214
217
220
223
226
228
229
230 // ##########################################################################
232 // ##########################################################################
233
235
238
241
243
244
245 // ##########################################################################
247 // ##########################################################################
248
250
252
270 virtual DBTranslatedValue translate(const std::string& str) final;
271
273
276 virtual std::string translateBack(const DBTranslatedValue translated_val) const final;
277
279
282 virtual std::size_t domainSize() const final;
283
285 virtual bool hasEditableDictionary() const final;
286
288 virtual void setEditableDictionaryMode(bool new_mode) final;
289
291 virtual bool needsReordering() const final;
292
295 virtual HashTable< std::size_t, std::size_t > reorder() final;
296
298 virtual const IDiscretizedVariable* variable() const final;
299
301 virtual DBTranslatedValue missingValue() const final;
302
304
305
306#ifndef DOXYGEN_SHOULD_SKIP_THIS
307
308 private:
309 // the DiscretizedVariable used for translations
311
312 // the DiscretizedVariable returned by method variable ()
313 // We must return a IDiscretizedVariable because the user may have
314 // saved into the translator a DiscretizedVariable<X>, with X != float
315 IDiscretizedVariable* _real_variable_;
316
317#endif /* DOXYGEN_SHOULD_SKIP_THIS */
318 };
319
320
321 } /* namespace learning */
322
323} /* namespace gum */
324
325// always include the template implementation
327
328// include the inlined functions if necessary
329#ifndef GUM_NO_INLINE
331#endif /* GUM_NO_INLINE */
332
333#endif /* GUM_LEARNING_DB_TRANSLATOR_4_DISCRETIZED_VARIABLE_H */
The databases' cell translators for discretized variables.
The base class for all the tabular databases' cell translators.
Class for discretized random variable.
The class for generic Hash Tables.
Definition hashTable.h:637
A base class for discretized variables, independent of the ticks type.
DBTranslator4DiscretizedVariable(const DiscretizedVariable< GUM_SCALAR > &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 discretized variable as translator
virtual bool hasEditableDictionary() const final
indicates that the translator is never in editable dictionary mode
DBTranslator4DiscretizedVariable(const IDiscretizedVariable &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 IDiscretized variable as translator
virtual HashTable< std::size_t, std::size_t > reorder() final
returns an empty HashTable to indicate that no reordering is needed.
DBTranslator4DiscretizedVariable(const DBTranslator4DiscretizedVariable &from)
copy constructor
DBTranslator4DiscretizedVariable & operator=(DBTranslator4DiscretizedVariable &&from)
move operator
virtual std::size_t domainSize() const final
returns the number of discretization intervals used for translations
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
DBTranslator4DiscretizedVariable & operator=(const DBTranslator4DiscretizedVariable &from)
copy operator
virtual void setEditableDictionaryMode(bool new_mode) final
sets/unset the editable dictionary mode
DBTranslator4DiscretizedVariable(const DiscretizedVariable< GUM_SCALAR > &var, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a discretized variable as translator but without missing symbols
virtual bool needsReordering() const final
indicates that the translations should never be reordered
virtual DBTranslator4DiscretizedVariable * clone() const
virtual copy constructor
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual const IDiscretizedVariable * variable() const final
returns the variable stored into the translator
DBTranslator4DiscretizedVariable(const IDiscretizedVariable &var, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a IDiscretized variable as translator but without missing symbols
DBTranslator4DiscretizedVariable(DBTranslator4DiscretizedVariable &&from)
move constructor
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
DBTranslator(DBTranslatedValueType val_type, const bool is_lossless, const std::vector< std::string > &missing_symbols, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
The union class for storing the translated values in learning databases.