Adds the given single sample to the trainer, setting the classid appropriately from the given unichar_str.
| 184 | // Adds the given single sample to the trainer, setting the classid |
| 185 | // appropriately from the given unichar_str. |
| 186 | void 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 |
no test coverage detected