aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
DBTranslatorSet_tpl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/** @file
23
* @brief The set of translators stored into a row filter
24
*
25
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26
*/
27
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
28
29
namespace
gum
{
30
31
namespace
learning
{
32
33
/// returns the allocator used by the translator set
34
template
<
template
<
typename
>
class
ALLOC >
35
typename
DBTranslatorSet<
ALLOC
>::
allocator_type
36
DBTranslatorSet
<
ALLOC
>::
getAllocator
()
const
{
37
return
columns__
.
get_allocator
();
38
}
39
40
41
/// remove all the translators from the vector
42
template
<
template
<
typename
>
class
ALLOC
>
43
void
DBTranslatorSet
<
ALLOC
>::
clear
() {
44
ALLOC
<
DBTranslator
<
ALLOC
> >
allocator
(
this
->
getAllocator
());
45
for
(
auto
translator
:
translators__
) {
46
allocator
.
destroy
(
translator
);
47
allocator
.
deallocate
(
translator
, 1);
48
}
49
50
translators__
.
clear
();
51
columns__
.
clear
();
52
highest_column__
=
std
::
size_t
(0);
53
}
54
55
56
/// copy the content of another translator set that uses another allocator
57
template
<
template
<
typename
>
class
ALLOC
>
58
void
DBTranslatorSet
<
ALLOC
>::
copy__
(
59
const
DBTranslatorSet
<
ALLOC
>&
from
,
60
const
typename
DBTranslatorSet
<
ALLOC
>::
allocator_type
&
alloc
) {
61
if
(
translators__
.
size
() != 0)
clear
();
62
63
// resize the vectors used in the set. First, we reserve new memory. This
64
// will keep the DBTranslatorSet in a correct state, even if the memory
65
// allocation fails
66
const
std
::
size_t
size
=
from
.
translators__
.
size
();
67
translators__
.
reserve
(
size
);
68
columns__
.
reserve
(
size
);
69
translators__
.
resize
(
size
);
70
columns__
.
resize
(
size
);
71
72
std
::
size_t
i
;
73
try
{
74
for
(
i
=
std
::
size_t
(0);
i
<
size
; ++
i
) {
75
translators__
[
i
] =
from
.
translators__
[
i
]->
clone
(
alloc
);
76
columns__
[
i
] =
from
.
columns__
[
i
];
77
}
78
}
catch
(...) {
79
translators__
.
resize
(
i
);
80
clear
();
81
throw
;
82
}
83
84
highest_column__
=
from
.
highest_column__
;
85
}
86
87
88
/// default constructor
89
template
<
template
<
typename
>
class
ALLOC
>
90
INLINE
DBTranslatorSet
<
ALLOC
>::
DBTranslatorSet
(
91
const
typename
DBTranslatorSet
<
ALLOC
>::
allocator_type
&
alloc
) :
92
translators__
(
alloc
),
93
columns__
(
allocator_type
(
alloc
)) {
94
GUM_CONSTRUCTOR
(
DBTranslatorSet
);
95
}
96
97
98
/// copy constructor with a given allocator
99
template
<
template
<
typename
>
class
ALLOC
>
100
INLINE
DBTranslatorSet
<
ALLOC
>::
DBTranslatorSet
(
101
const
DBTranslatorSet
<
ALLOC
>&
from
,
102
const
typename
DBTranslatorSet
<
ALLOC
>::
allocator_type
&
alloc
) :
103
translators__
(
alloc
),
104
columns__
(
alloc
) {
105
copy__
(
from
,
alloc
);
106
107
GUM_CONS_CPY
(
DBTranslatorSet
);
108
}
109
110
111
/// copy constructor
112
template
<
template
<
typename
>
class
ALLOC
>
113
INLINE
DBTranslatorSet
<
ALLOC
>::
DBTranslatorSet
(
114
const
DBTranslatorSet
<
ALLOC
>&
from
) :
115
DBTranslatorSet
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
116
117
118
/// move constructor with a given allocator
119
template
<
template
<
typename
>
class
ALLOC
>
120
INLINE
DBTranslatorSet
<
ALLOC
>::
DBTranslatorSet
(
121
DBTranslatorSet
<
ALLOC
>&&
from
,
122
const
typename
DBTranslatorSet
<
ALLOC
>::
allocator_type
&
alloc
) :
123
translators__
(
std
::
move
(
from
.
translators__
),
alloc
),
124
columns__
(
std
::
move
(
from
.
columns__
),
alloc
),
125
highest_column__
(
from
.
highest_column__
) {
126
GUM_CONS_MOV
(
DBTranslatorSet
);
127
}
128
129
130
/// move constructor
131
template
<
template
<
typename
>
class
ALLOC
>
132
INLINE
133
DBTranslatorSet
<
ALLOC
>::
DBTranslatorSet
(
DBTranslatorSet
<
ALLOC
>&&
from
) :
134
DBTranslatorSet
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
135
136
137
/// virtual copy constructor with a given allocator
138
template
<
template
<
typename
>
class
ALLOC
>
139
DBTranslatorSet
<
ALLOC
>*
DBTranslatorSet
<
ALLOC
>::
clone
(
140
const
typename
DBTranslatorSet
<
ALLOC
>::
allocator_type
&
alloc
)
const
{
141
ALLOC
<
DBTranslatorSet
<
ALLOC
> >
allocator
(
alloc
);
142
DBTranslatorSet
<
ALLOC
>*
set
=
allocator
.
allocate
(1);
143
try
{
144
allocator
.
construct
(
set
, *
this
,
alloc
);
145
}
catch
(...) {
146
allocator
.
deallocate
(
set
, 1);
147
throw
;
148
}
149
return
set
;
150
}
151
152
153
/// virtual copy constructor
154
template
<
template
<
typename
>
class
ALLOC
>
155
DBTranslatorSet
<
ALLOC
>*
DBTranslatorSet
<
ALLOC
>::
clone
()
const
{
156
return
clone
(
this
->
getAllocator
());
157
}
158
159
160
/// destructor
161
template
<
template
<
typename
>
class
ALLOC
>
162
INLINE
DBTranslatorSet
<
ALLOC
>::~
DBTranslatorSet
() {
163
clear
();
164
GUM_DESTRUCTOR
(
DBTranslatorSet
);
165
}
166
167
168
/// copy operator
169
template
<
template
<
typename
>
class
ALLOC
>
170
DBTranslatorSet
<
ALLOC
>&
171
DBTranslatorSet
<
ALLOC
>::
operator
=(
const
DBTranslatorSet
<
ALLOC
>&
from
) {
172
if
(
this
!= &
from
) {
173
clear
();
174
copy__
(
from
,
this
->
getAllocator
());
175
}
176
177
return
*
this
;
178
}
179
180
181
/// move operator
182
template
<
template
<
typename
>
class
ALLOC
>
183
INLINE
DBTranslatorSet
<
ALLOC
>&
184
DBTranslatorSet
<
ALLOC
>::
operator
=(
DBTranslatorSet
<
ALLOC
>&&
from
) {
185
if
(
this
!= &
from
) {
186
clear
();
187
translators__
=
std
::
move
(
from
.
translators__
);
188
columns__
=
std
::
move
(
from
.
columns__
);
189
highest_column__
=
from
.
highest_column__
;
190
}
191
192
return
*
this
;
193
}
194
195
196
/// returns the ith translator
197
template
<
template
<
typename
>
class
ALLOC
>
198
INLINE
DBTranslator
<
ALLOC
>&
199
DBTranslatorSet
<
ALLOC
>::
operator
[](
const
std
::
size_t
k
) {
200
return
*(
translators__
[
k
]);
201
}
202
203
204
/// returns the ith translator
205
template
<
template
<
typename
>
class
ALLOC
>
206
INLINE
const
DBTranslator
<
ALLOC
>&
207
DBTranslatorSet
<
ALLOC
>::
operator
[](
const
std
::
size_t
k
)
const
{
208
return
*(
translators__
[
k
]);
209
}
210
211
212
/// inserts a new translator at the end of the translator set
213
template
<
template
<
typename
>
class
ALLOC
>
214
template
<
template
<
template
<
typename
>
class
>
class
Translator
>
215
std
::
size_t
DBTranslatorSet
<
ALLOC
>::
insertTranslator
(
216
const
Translator
<
ALLOC
>&
translator
,
217
const
std
::
size_t
column
,
218
const
bool
unique_column
) {
219
// if the unique_column parameter is set to true and there exists already
220
// another translator that parses the column, raise a DuplicateElement
221
// exception
222
const
std
::
size_t
size
=
translators__
.
size
();
223
if
(
unique_column
) {
224
for
(
std
::
size_t
i
=
std
::
size_t
(0);
i
<
size
; ++
i
) {
225
if
(
columns__
[
i
] ==
column
)
226
GUM_ERROR
(
DuplicateElement
,
227
"There already exists a DBTranslator that parses Column"
228
<<
column
);
229
}
230
}
231
232
// reserve some place for the new translator
233
translators__
.
reserve
(
size
+ 1);
234
columns__
.
reserve
(
size
+ 1);
235
236
// create and add the new translator
237
ALLOC
<
DBTranslator
<
ALLOC
> >
allocator
(
this
->
getAllocator
());
238
DBTranslator
<
ALLOC
>*
new_translator
=
translator
.
clone
(
allocator
);
239
240
translators__
.
resize
(
size
+ 1);
241
columns__
.
resize
(
size
+ 1);
242
translators__
[
size
] =
new_translator
;
243
columns__
[
size
] =
column
;
244
245
// update the highest column
246
if
(
column
>
highest_column__
)
highest_column__
=
column
;
247
248
return
size
;
249
}
250
251
252
/// inserts a new translator for a given variable in the translator set
253
template
<
template
<
typename
>
class
ALLOC
>
254
template
<
template
<
typename
>
class
XALLOC
>
255
std
::
size_t
DBTranslatorSet
<
ALLOC
>::
insertTranslator
(
256
const
Variable
&
var
,
257
const
std
::
size_t
column
,
258
const
std
::
vector
<
std
::
string
,
XALLOC
<
std
::
string
> >&
missing_symbols
,
259
const
bool
unique_column
) {
260
// create the translatator, depending on the type of the variable
261
switch
(
var
.
varType
()) {
262
case
VarType
::
Labelized
: {
263
const
LabelizedVariable
&
xvar
264
=
static_cast
<
const
LabelizedVariable
& >(
var
);
265
DBTranslator4LabelizedVariable
<
ALLOC
>
translator
(
xvar
,
266
missing_symbols
);
267
return
insertTranslator
(
translator
,
column
,
unique_column
);
268
}
269
270
case
VarType
::
Discretized
: {
271
const
IDiscretizedVariable
&
xvar
272
=
static_cast
<
const
IDiscretizedVariable
& >(
var
);
273
DBTranslator4DiscretizedVariable
<
ALLOC
>
translator
(
xvar
,
274
missing_symbols
);
275
return
insertTranslator
(
translator
,
column
,
unique_column
);
276
}
277
278
case
VarType
::
Range
: {
279
const
RangeVariable
&
xvar
=
static_cast
<
const
RangeVariable
& >(
var
);
280
DBTranslator4RangeVariable
<
ALLOC
>
translator
(
xvar
,
missing_symbols
);
281
return
insertTranslator
(
translator
,
column
,
unique_column
);
282
}
283
284
case
VarType
::
Continuous
: {
285
const
IContinuousVariable
&
xvar
286
=
static_cast
<
const
IContinuousVariable
& >(
var
);
287
DBTranslator4ContinuousVariable
<
ALLOC
>
translator
(
xvar
,
288
missing_symbols
);
289
return
insertTranslator
(
translator
,
column
,
unique_column
);
290
}
291
292
default
:
293
GUM_ERROR
(
NotImplementedYet
,
294
"The insertion of the translator for Variable "
295
<<
var
.
name
()
296
<<
" is impossible because a translator "
297
"for such variable is not implemented yet"
);
298
}
299
}
300
301
302
/// inserts a new translator for a given variable in the translator set
303
template
<
template
<
typename
>
class
ALLOC
>
304
INLINE
std
::
size_t
305
DBTranslatorSet
<
ALLOC
>::
insertTranslator
(
const
Variable
&
var
,
306
const
std
::
size_t
column
,
307
const
bool
unique_column
) {
308
const
std
::
vector
<
std
::
string
,
ALLOC
<
std
::
string
> >
missing
;
309
return
this
->
insertTranslator
(
var
,
column
,
missing
,
unique_column
);
310
}
311
312
313
/// erase the kth translator
314
template
<
template
<
typename
>
class
ALLOC
>
315
void
DBTranslatorSet
<
ALLOC
>::
eraseTranslator
(
const
std
::
size_t
k
,
316
const
bool
k_is_input_col
) {
317
ALLOC
<
DBTranslator
<
ALLOC
> >
allocator
(
this
->
getAllocator
());
318
const
std
::
size_t
nb_trans
=
translators__
.
size
();
319
320
if
(!
k_is_input_col
) {
321
if
(
nb_trans
<
k
)
return
;
322
323
// remove the translator and its corresponding column
324
allocator
.
destroy
(
translators__
[
k
]);
325
allocator
.
deallocate
(
translators__
[
k
], 1);
326
327
const
std
::
size_t
colk
=
columns__
[
k
];
328
translators__
.
erase
(
translators__
.
begin
() +
k
);
329
columns__
.
erase
(
columns__
.
begin
() +
k
);
330
331
// if the highest column index corresponded to the kth translator,
332
// we must recomput it
333
if
(
highest_column__
==
colk
) {
334
highest_column__
=
std
::
size_t
(0);
335
for
(
const
auto
col
:
columns__
)
336
if
(
highest_column__
<
col
)
highest_column__
=
col
;
337
}
338
}
else
{
339
// remove all the translators parsing the kth column
340
auto
iter_trans
=
translators__
.
rbegin
();
341
bool
translator_found
=
false
;
342
for
(
auto
iter_col
=
columns__
.
rbegin
();
iter_col
!=
columns__
.
rend
();
343
++
iter_col
, ++
iter_trans
) {
344
if
(*
iter_col
==
k
) {
345
// remove the translator and its corresponding column
346
allocator
.
destroy
(*
iter_trans
);
347
allocator
.
deallocate
(*
iter_trans
, 1);
348
349
translators__
.
erase
((
iter_trans
+ 1).
base
());
350
columns__
.
erase
((
iter_col
+ 1).
base
());
351
translator_found
=
true
;
352
}
353
}
354
355
// if the highest column index corresponded to one of the translators
356
// removed, we must recompute it
357
if
(
translator_found
&& (
k
==
highest_column__
)) {
358
highest_column__
=
std
::
size_t
(0);
359
for
(
const
auto
col
:
columns__
)
360
if
(
highest_column__
<
col
)
highest_column__
=
col
;
361
}
362
}
363
}
364
365
366
/// ask the kth translator to translate a string in a row of the database
367
template
<
template
<
typename
>
class
ALLOC
>
368
template
<
template
<
typename
>
class
OTHER_ALLOC
>
369
INLINE
DBTranslatedValue
DBTranslatorSet
<
ALLOC
>::
translate
(
370
const
std
::
vector
<
std
::
string
,
OTHER_ALLOC
<
std
::
string
> >&
row
,
371
const
std
::
size_t
k
)
const
{
372
return
translators__
[
k
]->
translate
(
row
[
columns__
[
k
]]);
373
}
374
375
376
/// ask the kth translator to translate a string in a row of the database
377
template
<
template
<
typename
>
class
ALLOC
>
378
template
<
template
<
typename
>
class
OTHER_ALLOC
>
379
INLINE
DBTranslatedValue
DBTranslatorSet
<
ALLOC
>::
translateSafe
(
380
const
std
::
vector
<
std
::
string
,
OTHER_ALLOC
<
std
::
string
> >&
row
,
381
const
std
::
size_t
k
)
const
{
382
if
(
translators__
.
size
() <=
k
)
383
GUM_ERROR
(
UndefinedElement
,
"Translator #"
<<
k
<<
" could not be found"
);
384
return
translators__
[
k
]->
translate
(
row
[
columns__
[
k
]]);
385
}
386
387
388
/// returns the original string that was translated into translated_val
389
template
<
template
<
typename
>
class
ALLOC
>
390
INLINE
std
::
string
DBTranslatorSet
<
ALLOC
>::
translateBack
(
391
const
DBTranslatedValue
translated_val
,
392
const
std
::
size_t
k
)
const
{
393
return
translators__
[
k
]->
translateBack
(
translated_val
);
394
}
395
396
397
/// returns the original string that was translated into translated_val
398
template
<
template
<
typename
>
class
ALLOC
>
399
INLINE
std
::
string
DBTranslatorSet
<
ALLOC
>::
translateBackSafe
(
400
const
DBTranslatedValue
translated_val
,
401
const
std
::
size_t
k
)
const
{
402
if
(
translators__
.
size
() <=
k
)
403
GUM_ERROR
(
UndefinedElement
,
"Translator #"
<<
k
<<
"could not be found"
);
404
return
translators__
[
k
]->
translateBack
(
translated_val
);
405
}
406
407
408
// indicates whether the kth translator considers a translated_val
409
// as a missing value
410
template
<
template
<
typename
>
class
ALLOC
>
411
INLINE
bool
DBTranslatorSet
<
ALLOC
>::
isMissingValue
(
412
const
DBTranslatedValue
translated_val
,
413
const
std
::
size_t
k
)
const
{
414
return
translators__
[
k
]->
isMissingValue
(
translated_val
);
415
}
416
417
418
// indicates whether the kth translator considers a translated_val
419
// as a missing value
420
template
<
template
<
typename
>
class
ALLOC
>
421
INLINE
bool
DBTranslatorSet
<
ALLOC
>::
isMissingValueSafe
(
422
const
DBTranslatedValue
translated_val
,
423
const
std
::
size_t
k
)
const
{
424
if
(
translators__
.
size
() <=
k
)
425
GUM_ERROR
(
UndefinedElement
,
"Translator #"
<<
k
<<
"could not be found"
);
426
return
translators__
[
k
]->
isMissingValue
(
translated_val
);
427
}
428
429
430
/// returns the kth translator
431
template
<
template
<
typename
>
class
ALLOC
>
432
INLINE
DBTranslator
<
ALLOC
>&
433
DBTranslatorSet
<
ALLOC
>::
translator
(
const
std
::
size_t
k
) {
434
return
*(
translators__
[
k
]);
435
}
436
437
438
/// returns the kth translator
439
template
<
template
<
typename
>
class
ALLOC
>
440
INLINE
const
DBTranslator
<
ALLOC
>&
441
DBTranslatorSet
<
ALLOC
>::
translator
(
const
std
::
size_t
k
)
const
{
442
return
*(
translators__
[
k
]);
443
}
444
445
446
/// returns the kth translator
447
template
<
template
<
typename
>
class
ALLOC
>
448
INLINE
DBTranslator
<
ALLOC
>&
449
DBTranslatorSet
<
ALLOC
>::
translatorSafe
(
const
std
::
size_t
k
) {
450
if
(
translators__
.
size
() <=
k
)
451
GUM_ERROR
(
UndefinedElement
,
"Translator #"
<<
k
<<
"could not be found"
);
452
return
*(
translators__
[
k
]);
453
}
454
455
456
/// returns the kth translator
457
template
<
template
<
typename
>
class
ALLOC
>
458
INLINE
const
DBTranslator
<
ALLOC
>&
459
DBTranslatorSet
<
ALLOC
>::
translatorSafe
(
const
std
::
size_t
k
)
const
{
460
if
(
translators__
.
size
() <=
k
)
461
GUM_ERROR
(
UndefinedElement
,
"Translator #"
<<
k
<<
"could not be found"
);
462
return
*(
translators__
[
k
]);
463
}
464
465
466
/// returns the domain size of the variables stored into the kth translator
467
template
<
template
<
typename
>
class
ALLOC
>
468
INLINE
std
::
size_t
469
DBTranslatorSet
<
ALLOC
>::
domainSize
(
const
std
::
size_t
k
)
const
{
470
return
translators__
[
k
]->
domainSize
();
471
}
472
473
474
/// returns the domain size of the variables stored into the kth translator
475
template
<
template
<
typename
>
class
ALLOC
>
476
INLINE
std
::
size_t
477
DBTranslatorSet
<
ALLOC
>::
domainSizeSafe
(
const
std
::
size_t
k
)
const
{
478
if
(
translators__
.
size
() <=
k
)
479
GUM_ERROR
(
UndefinedElement
,
"Variable #"
<<
k
<<
"could not be found"
);
480
return
translators__
[
k
]->
domainSize
();
481
}
482
483
484
/// returns the variable stored into the kth translator
485
template
<
template
<
typename
>
class
ALLOC
>
486
INLINE
const
Variable
&
487
DBTranslatorSet
<
ALLOC
>::
variable
(
const
std
::
size_t
k
)
const
{
488
return
*(
translators__
[
k
]->
variable
());
489
}
490
491
492
/// returns the variable stored into the kth translator
493
template
<
template
<
typename
>
class
ALLOC
>
494
INLINE
const
Variable
&
495
DBTranslatorSet
<
ALLOC
>::
variableSafe
(
const
std
::
size_t
k
)
const
{
496
if
(
translators__
.
size
() <=
k
)
497
GUM_ERROR
(
UndefinedElement
,
"Variable #"
<<
k
<<
"could not be found"
);
498
return
*(
translators__
[
k
]->
variable
());
499
}
500
501
502
// indicates whether a reordering is needed to make the kth translator
503
// sorted by lexicographical order
504
template
<
template
<
typename
>
class
ALLOC
>
505
INLINE
bool
506
DBTranslatorSet
<
ALLOC
>::
needsReordering
(
const
std
::
size_t
k
)
const
{
507
return
translators__
[
k
]->
needsReordering
();
508
}
509
510
511
// indicates whether a reordering is needed to make the kth translator
512
// sorted by lexicographical order
513
template
<
template
<
typename
>
class
ALLOC
>
514
INLINE
bool
515
DBTranslatorSet
<
ALLOC
>::
needsReorderingSafe
(
const
std
::
size_t
k
)
const
{
516
if
(
translators__
.
size
() <=
k
)
517
GUM_ERROR
(
UndefinedElement
,
"Variable #"
<<
k
<<
"could not be found"
);
518
return
translators__
[
k
]->
needsReordering
();
519
}
520
521
522
// performs a reordering of the dictionary and returns a mapping
523
// from the old translated values to the new ones.
524
template
<
template
<
typename
>
class
ALLOC
>
525
INLINE
HashTable
<
std
::
size_t
,
526
std
::
size_t
,
527
ALLOC
<
std
::
pair
<
std
::
size_t
,
std
::
size_t
> > >
528
DBTranslatorSet
<
ALLOC
>::
reorder
(
const
std
::
size_t
k
) {
529
return
translators__
[
k
]->
reorder
();
530
}
531
532
533
// performs a reordering of the dictionary and returns a mapping
534
// from the old translated values to the new ones.
535
template
<
template
<
typename
>
class
ALLOC
>
536
INLINE
HashTable
<
std
::
size_t
,
537
std
::
size_t
,
538
ALLOC
<
std
::
pair
<
std
::
size_t
,
std
::
size_t
> > >
539
DBTranslatorSet
<
ALLOC
>::
reorderSafe
(
const
std
::
size_t
k
) {
540
if
(
translators__
.
size
() <=
k
)
541
GUM_ERROR
(
UndefinedElement
,
"Variable #"
<<
k
<<
"could not be found"
);
542
return
translators__
[
k
]->
reorder
();
543
}
544
545
546
/** @brief returns the column of the input database that will be written
547
* in the kth column of the DatabaseTable */
548
template
<
template
<
typename
>
class
ALLOC
>
549
INLINE
std
::
size_t
550
DBTranslatorSet
<
ALLOC
>::
inputColumn
(
const
std
::
size_t
k
)
const
{
551
return
columns__
[
k
];
552
}
553
554
555
/** @brief returns the column of the input database that will be written
556
* in the kth column of the DatabaseTable */
557
template
<
template
<
typename
>
class
ALLOC
>
558
INLINE
std
::
size_t
559
DBTranslatorSet
<
ALLOC
>::
inputColumnSafe
(
const
std
::
size_t
k
)
const
{
560
if
(
translators__
.
size
() <=
k
)
561
GUM_ERROR
(
UndefinedElement
,
"Column #"
<<
k
<<
"could not be found"
);
562
return
columns__
[
k
];
563
}
564
565
566
/// returns the largest input database column index read by the translators
567
template
<
template
<
typename
>
class
ALLOC
>
568
INLINE
std
::
size_t
DBTranslatorSet
<
ALLOC
>::
highestInputColumn
()
const
{
569
return
highest_column__
;
570
}
571
572
573
/// returns the number of translators stored into the set
574
template
<
template
<
typename
>
class
ALLOC
>
575
INLINE
std
::
size_t
DBTranslatorSet
<
ALLOC
>::
nbTranslators
()
const
{
576
return
columns__
.
size
();
577
}
578
579
580
/// returns the number of translators stored into the set
581
template
<
template
<
typename
>
class
ALLOC
>
582
INLINE
std
::
size_t
DBTranslatorSet
<
ALLOC
>::
size
()
const
{
583
return
columns__
.
size
();
584
}
585
586
/// returns the set of translators
587
template
<
template
<
typename
>
class
ALLOC
>
588
INLINE
const
589
std
::
vector
<
DBTranslator
<
ALLOC
>*,
ALLOC
<
DBTranslator
<
ALLOC
>* > >&
590
DBTranslatorSet
<
ALLOC
>::
translators
()
const
{
591
return
translators__
;
592
}
593
594
}
/* namespace learning */
595
596
}
/* namespace gum */
597
598
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
gum::learning::genericBNLearner::Database::Database
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
Definition:
genericBNLearner_tpl.h:31