aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBTranslator4LabelizedVariable.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_LABELIZED_VARIABLE_H
48#define GUM_LEARNING_DB_TRANSLATOR_4_LABELIZED_VARIABLE_H
49
50
51#include <agrum/agrum.h>
52
56
57namespace gum {
58
59 namespace learning {
60
61
156 public:
157 // ##########################################################################
159 // ##########################################################################
160
162
164
175 DBTranslator4LabelizedVariable(const std::vector< std::string >& missing_symbols,
176 std::size_t max_dico_entries
177 = std::numeric_limits< std::size_t >::max());
178
180
189 DBTranslator4LabelizedVariable(std::size_t max_dico_entries
190 = std::numeric_limits< std::size_t >::max());
191
193
210 const std::vector< std::string >& missing_symbols,
211 const bool editable_dictionary = false,
212 std::size_t max_dico_entries
213 = std::numeric_limits< std::size_t >::max());
214
233 const bool editable_dictionary = false,
234 std::size_t max_dico_entries
235 = std::numeric_limits< std::size_t >::max());
236
239
242
245
248
250
251
252 // ##########################################################################
254 // ##########################################################################
255
257
260
263
265
266
267 // ##########################################################################
269 // ##########################################################################
270
272
274
300 virtual DBTranslatedValue translate(const std::string& str) final;
301
303
309 virtual std::string translateBack(const DBTranslatedValue translated_val) const final;
310
312
319 virtual std::size_t domainSize() const final;
320
341 virtual bool needsReordering() const final;
342
352 virtual HashTable< std::size_t, std::size_t > reorder() final;
353
355 virtual const LabelizedVariable* variable() const final;
356
358 virtual DBTranslatedValue missingValue() const final;
359
361
362#ifndef DOXYGEN_SHOULD_SKIP_THIS
363
364 private:
365 // the LabelizedVariable assigned to the translator, if any
366 LabelizedVariable _variable_;
367
368#endif /* DOXYGEN_SHOULD_SKIP_THIS */
369 };
370
371
372 } /* namespace learning */
373
374} /* namespace gum */
375
377#ifndef GUM_NO_INLINE
379#endif /* GUM_NO_INLINE */
380
381#endif /* GUM_LEARNING_DB_TRANSLATOR_4_LABELIZED_VARIABLE_H */
The class representing the original values of the cells of databases.
The databases' cell translators for labelized variables.
The base class for all the tabular databases' cell translators.
The class for generic Hash Tables.
Definition hashTable.h:637
class LabelizedVariable
virtual bool needsReordering() const final
indicates whether a reordering is needed to make the translations sorted
DBTranslator4LabelizedVariable(const DBTranslator4LabelizedVariable &from)
copy constructor
DBTranslator4LabelizedVariable(DBTranslator4LabelizedVariable &&from)
move constructor
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
DBTranslator4LabelizedVariable(std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor without any initial variable nor missing symbols
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
DBTranslator4LabelizedVariable(const LabelizedVariable &var, const std::vector< std::string > &missing_symbols, const bool editable_dictionary=false, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a labelized variable as translator
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
virtual const LabelizedVariable * variable() const final
returns the variable stored into the translator
virtual HashTable< 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...
virtual DBTranslator4LabelizedVariable * clone() const
virtual copy constructor
DBTranslator4LabelizedVariable(const LabelizedVariable &var, const bool editable_dictionary=false, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a labelized variable as translator but without missing symbols
DBTranslator4LabelizedVariable(const std::vector< std::string > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor without any initial variable
virtual std::size_t domainSize() const final
returns the domain size of a variable corresponding to the translations
DBTranslator4LabelizedVariable & operator=(const DBTranslator4LabelizedVariable &from)
copy operator
DBTranslator4LabelizedVariable & operator=(DBTranslator4LabelizedVariable &&from)
move 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
Base class for labelized discrete random variables.
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.