1 #include "posgen.h" // -*- tab-width: 2 mode: c++ -*-
5 void Generator::init(const Sentence
&_st
)
8 nr_misspelled
= 3; // REMEMBER THIS NUMBER
9 len
= _st
.get_syllable_count();
10 pgen
.init(len
,nr_misspelled
);
13 void Generator::done()
19 Generate every possible 3-misspelled-positions.
20 Then call WFST::generate_misspelled_words.
23 bool Generator::step(vector
<uint
> &_pos
,uint
&_len
)
25 return pgen
.step(_pos
,_len
);
28 void PosGen::init(uint len_
,uint n_
)
37 for (i
= 0;i
< n
;i
++)
48 Generate every possible 3-misspelled-positions.
49 Then call WFST::generate_misspelled_words.
52 bool PosGen::step(vector
<uint
> &_pos
,uint
&_len
)
56 // move to the next counter
57 if (i
+1 < n
&& pos
[i
] < len
) {
60 // do something here with misspelled_pos[i]
66 // the last counter is not full
68 // do something here with misspelled_pos[nr_misspelled]
75 // the last counter is full, step back
76 while (i
>= 0 && pos
[i
] == len
) i
--;
81 for (ii
= i
+1;ii
< n
;ii
++)
82 pos
[ii
] = pos
[ii
-1]+1;