MCPcopy Create free account
hub / github.com/creatale/node-dv / AddSample

Method AddSample

deps/tesseract/classify/mastertrainer.cpp:186–211  ·  view source on GitHub ↗

Adds the given single sample to the trainer, setting the classid appropriately from the given unichar_str.

Source from the content-addressed store, hash-verified

184// Adds the given single sample to the trainer, setting the classid
185// appropriately from the given unichar_str.
186void MasterTrainer::AddSample(bool verification, const char* unichar,
187 TrainingSample* sample) {
188 if (verification) {
189 verify_samples_.AddSample(unichar, sample);
190 prev_unichar_id_ = -1;
191 } else if (unicharset_.contains_unichar(unichar)) {
192 if (prev_unichar_id_ >= 0)
193 fragments_[prev_unichar_id_] = -1;
194 prev_unichar_id_ = samples_.AddSample(unichar, sample);
195 if (flat_shapes_.FindShape(prev_unichar_id_, sample->font_id()) < 0)
196 flat_shapes_.AddShape(prev_unichar_id_, sample->font_id());
197 } else {
198 int junk_id = junk_samples_.AddSample(unichar, sample);
199 if (prev_unichar_id_ >= 0) {
200 CHAR_FRAGMENT* frag = CHAR_FRAGMENT::parse_from_string(unichar);
201 if (frag != NULL && frag->is_natural()) {
202 if (fragments_[prev_unichar_id_] == 0)
203 fragments_[prev_unichar_id_] = junk_id;
204 else if (fragments_[prev_unichar_id_] != junk_id)
205 fragments_[prev_unichar_id_] = -1;
206 }
207 delete frag;
208 }
209 prev_unichar_id_ = -1;
210 }
211}
212
213// Loads all pages from the given tif filename and append to page_images_.
214// Must be called after ReadTrainingSamples, as the current number of images

Callers 2

IncludeJunkMethod · 0.45

Calls 5

contains_unicharMethod · 0.80
FindShapeMethod · 0.80
font_idMethod · 0.80
AddShapeMethod · 0.80
is_naturalMethod · 0.80

Tested by

no test coverage detected