aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBTranslator4NumericalDiscreteVariable.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_NUMERICAL_DISCRETE_VARIABLE_H
48#define GUM_LEARNING_DB_TRANSLATOR_4_NUMERICAL_DISCRETE_VARIABLE_H
49
50#include <sstream>
51#include <utility>
52#include <vector>
53
54#include <agrum/agrum.h>
55
59
60namespace gum {
61
62 namespace learning {
63
64
143 public:
144 // ##########################################################################
146 // ##########################################################################
147
149
151
161 const std::vector< std::string >& missing_symbols,
162 std::size_t max_dico_entries
163 = std::numeric_limits< std::size_t >::max());
164
176 std::size_t max_dico_entries
177 = std::numeric_limits< std::size_t >::max());
178
181
184
187
190
192
193
194 // ##########################################################################
196 // ##########################################################################
197
199
203
207
209
210
211 // ##########################################################################
213 // ##########################################################################
214
216
218
235 virtual DBTranslatedValue translate(const std::string& str) final;
236
238
241 virtual std::string translateBack(const DBTranslatedValue translated_val) const final;
242
244
247 virtual std::size_t domainSize() const final;
248
250 virtual bool hasEditableDictionary() const final;
251
253 virtual void setEditableDictionaryMode(bool new_mode) final;
254
256 virtual bool needsReordering() const final;
257
260 virtual HashTable< std::size_t, std::size_t > reorder() final;
261
263 virtual const NumericalDiscreteVariable* variable() const final;
264
266 virtual DBTranslatedValue missingValue() const final;
267
269
270
271#ifndef DOXYGEN_SHOULD_SKIP_THIS
272
273 private:
274 // the NumericalDiscreteVariable used for translations
275 NumericalDiscreteVariable _variable_;
276
277
278#endif /* DOXYGEN_SHOULD_SKIP_THIS */
279 };
280
281
282 } /* namespace learning */
283
284} /* namespace gum */
285
287#ifndef GUM_NO_INLINE
289#endif /* GUM_NO_INLINE */
290
291#endif /* GUM_LEARNING_DB_TRANSLATOR_4_NUMERICAL_DISCRETE_VARIABLE_H */
The class representing the original values of the cells of databases.
The databases' cell translators for integer variables.
The base class for all the tabular databases' cell translators.
The class for generic Hash Tables.
Definition hashTable.h:637
class NumericalDiscreteVariable
DBTranslator4NumericalDiscreteVariable(const NumericalDiscreteVariable &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 numerical discrete variable as translator
virtual const NumericalDiscreteVariable * variable() const final
returns the variable stored into the translator
virtual bool hasEditableDictionary() const final
indicates that the translator is never in editable dictionary mode
DBTranslator4NumericalDiscreteVariable(const DBTranslator4NumericalDiscreteVariable &from)
copy constructor
virtual DBTranslator4NumericalDiscreteVariable * clone() const
virtual copy constructor
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual std::size_t domainSize() const final
returns the domain size of the variable used for translations
DBTranslator4NumericalDiscreteVariable(DBTranslator4NumericalDiscreteVariable &&from)
move constructor
DBTranslator4NumericalDiscreteVariable(const NumericalDiscreteVariable &var, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a numerical discrete variable as translator but without missing symbols
virtual bool needsReordering() const final
indicates that the translations should never be reordered
DBTranslator4NumericalDiscreteVariable & operator=(DBTranslator4NumericalDiscreteVariable &&from)
move operator
virtual HashTable< std::size_t, std::size_t > reorder() final
returns an empty HashTable to indicate that no reordering is needed.
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
virtual void setEditableDictionaryMode(bool new_mode) final
sets/unset the editable dictionary mode
DBTranslator4NumericalDiscreteVariable & operator=(const DBTranslator4NumericalDiscreteVariable &from)
copy operator
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.
Base class for numerical discrete random variables.
The union class for storing the translated values in learning databases.