@@ -220,17 +220,15 @@ void Classify::RefreshDebugWindow(ScrollView **win, const char *msg,
220
220
221
221
// Learns the given word using its chopped_word, seam_array, denorm,
222
222
// box_word, best_state, and correct_text to learn both correctly and
223
- // incorrectly segmented blobs. If filename is not NULL, then LearnBlob
224
- // is called and the data will be written to a file for static training .
223
+ // incorrectly segmented blobs. If fontname is not NULL, then LearnBlob
224
+ // is called and the data will be saved in an internal buffer .
225
225
// Otherwise AdaptToBlob is called for adaption within a document.
226
- // If rejmap is not NULL, then only chars with a rejmap entry of '1' will
227
- // be learned, otherwise all chars with good correct_text are learned.
228
- void Classify::LearnWord (const char * filename, WERD_RES *word) {
226
+ void Classify::LearnWord (const char * fontname, WERD_RES* word) {
229
227
int word_len = word->correct_text .size ();
230
228
if (word_len == 0 ) return ;
231
229
232
230
float * thresholds = NULL ;
233
- if (filename == NULL ) {
231
+ if (fontname == NULL ) {
234
232
// Adaption mode.
235
233
if (!EnableLearning || word->best_choice == NULL )
236
234
return ; // Can't or won't adapt.
@@ -267,8 +265,8 @@ void Classify::LearnWord(const char* filename, WERD_RES *word) {
267
265
if (word->correct_text [ch].length () > 0 ) {
268
266
float threshold = thresholds != NULL ? thresholds[ch] : 0 .0f ;
269
267
270
- LearnPieces (filename , start_blob, word->best_state [ch],
271
- threshold, CST_WHOLE, word->correct_text [ch].string (), word);
268
+ LearnPieces (fontname , start_blob, word->best_state [ch], threshold ,
269
+ CST_WHOLE, word->correct_text [ch].string (), word);
272
270
273
271
if (word->best_state [ch] > 1 && !disable_character_fragments) {
274
272
// Check that the character breaks into meaningful fragments
@@ -301,8 +299,8 @@ void Classify::LearnWord(const char* filename, WERD_RES *word) {
301
299
if (i != tokens.size () - 1 )
302
300
full_string += ' ' ;
303
301
}
304
- LearnPieces (filename , start_blob + frag, 1 ,
305
- threshold, CST_FRAGMENT, full_string.string (), word);
302
+ LearnPieces (fontname , start_blob + frag, 1 , threshold ,
303
+ CST_FRAGMENT, full_string.string (), word);
306
304
}
307
305
}
308
306
}
@@ -314,13 +312,13 @@ void Classify::LearnWord(const char* filename, WERD_RES *word) {
314
312
if (word->best_state[ch] > 1) {
315
313
// If the next blob is good, make junk with the rightmost fragment.
316
314
if (ch + 1 < word_len && word->correct_text[ch + 1].length() > 0) {
317
- LearnPieces(filename , start_blob + word->best_state[ch] - 1,
315
+ LearnPieces(fontname , start_blob + word->best_state[ch] - 1,
318
316
word->best_state[ch + 1] + 1,
319
317
threshold, CST_IMPROPER, INVALID_UNICHAR, word);
320
318
}
321
319
// If the previous blob is good, make junk with the leftmost fragment.
322
320
if (ch > 0 && word->correct_text[ch - 1].length() > 0) {
323
- LearnPieces(filename , start_blob - word->best_state[ch - 1],
321
+ LearnPieces(fontname , start_blob - word->best_state[ch - 1],
324
322
word->best_state[ch - 1] + 1,
325
323
threshold, CST_IMPROPER, INVALID_UNICHAR, word);
326
324
}
@@ -329,7 +327,7 @@ void Classify::LearnWord(const char* filename, WERD_RES *word) {
329
327
if (ch + 1 < word_len && word->correct_text[ch + 1].length() > 0) {
330
328
STRING joined_text = word->correct_text[ch];
331
329
joined_text += word->correct_text[ch + 1];
332
- LearnPieces(filename , start_blob,
330
+ LearnPieces(fontname , start_blob,
333
331
word->best_state[ch] + word->best_state[ch + 1],
334
332
threshold, CST_NGRAM, joined_text.string(), word);
335
333
}
@@ -342,16 +340,16 @@ void Classify::LearnWord(const char* filename, WERD_RES *word) {
342
340
343
341
// Builds a blob of length fragments, from the word, starting at start,
344
342
// and then learns it, as having the given correct_text.
345
- // If filename is not NULL, then LearnBlob
346
- // is called and the data will be written to a file for static training.
343
+ // If fontname is not NULL, then LearnBlob is called and the data will be
344
+ // saved in an internal buffer for static training.
347
345
// Otherwise AdaptToBlob is called for adaption within a document.
348
346
// threshold is a magic number required by AdaptToChar and generated by
349
347
// ComputeAdaptionThresholds.
350
348
// Although it can be partly inferred from the string, segmentation is
351
349
// provided to explicitly clarify the character segmentation.
352
- void Classify::LearnPieces (const char * filename , int start, int length,
350
+ void Classify::LearnPieces (const char * fontname , int start, int length,
353
351
float threshold, CharSegmentationType segmentation,
354
- const char * correct_text, WERD_RES * word) {
352
+ const char * correct_text, WERD_RES* word) {
355
353
// TODO(daria) Remove/modify this if/when we want
356
354
// to train and/or adapt to n-grams.
357
355
if (segmentation != CST_WHOLE &&
@@ -385,16 +383,15 @@ void Classify::LearnPieces(const char* filename, int start, int length,
385
383
}
386
384
#endif // GRAPHICS_DISABLED
387
385
388
- if (filename != NULL ) {
386
+ if (fontname != NULL ) {
389
387
classify_norm_method.set_value (character); // force char norm spc 30/11/93
390
388
tess_bn_matching.set_value (false ); // turn it off
391
389
tess_cn_matching.set_value (false );
392
390
DENORM bl_denorm, cn_denorm;
393
391
INT_FX_RESULT_STRUCT fx_info;
394
392
SetupBLCNDenorms (*rotated_blob, classify_nonlinear_norm,
395
393
&bl_denorm, &cn_denorm, &fx_info);
396
- LearnBlob (feature_defs_, filename, rotated_blob, bl_denorm, cn_denorm,
397
- fx_info, correct_text);
394
+ LearnBlob (fontname, rotated_blob, cn_denorm, fx_info, correct_text);
398
395
} else if (unicharset.contains_unichar (correct_text)) {
399
396
UNICHAR_ID class_id = unicharset.unichar_to_id (correct_text);
400
397
int font_id = word->fontinfo != NULL
0 commit comments