* Try splitting off the given number of (chopped) blobs from the front and * back of the given word and recognizing the pieces. * * @param[in] num_chopped_leading how many chopped blobs from the left * end of the word to chop off and try recognizing as a * superscript (or subscript) * @param[in] leading_certainty the (minimum) certainty had by th
| 380 | * @return A word which is the result of re-recognizing as asked. |
| 381 | */ |
| 382 | WERD_RES *Tesseract::TrySuperscriptSplits( |
| 383 | int num_chopped_leading, float leading_certainty, ScriptPos leading_pos, |
| 384 | int num_chopped_trailing, float trailing_certainty, |
| 385 | ScriptPos trailing_pos, |
| 386 | WERD_RES *word, |
| 387 | bool *is_good, |
| 388 | int *retry_rebuild_leading, int *retry_rebuild_trailing) { |
| 389 | int num_chopped = word->chopped_word->NumBlobs(); |
| 390 | |
| 391 | *retry_rebuild_leading = *retry_rebuild_trailing = 0; |
| 392 | |
| 393 | // Chop apart the word into up to three pieces. |
| 394 | |
| 395 | BlamerBundle *bb0 = NULL; |
| 396 | BlamerBundle *bb1 = NULL; |
| 397 | WERD_RES *prefix = NULL; |
| 398 | WERD_RES *core = NULL; |
| 399 | WERD_RES *suffix = NULL; |
| 400 | if (num_chopped_leading > 0) { |
| 401 | prefix = new WERD_RES(*word); |
| 402 | split_word(prefix, num_chopped_leading, &core, &bb0); |
| 403 | } else { |
| 404 | core = new WERD_RES(*word); |
| 405 | } |
| 406 | |
| 407 | if (num_chopped_trailing > 0) { |
| 408 | int split_pt = num_chopped - num_chopped_trailing - num_chopped_leading; |
| 409 | split_word(core, split_pt, &suffix, &bb1); |
| 410 | } |
| 411 | |
| 412 | // Recognize the pieces in turn. |
| 413 | int saved_cp_multiplier = classify_class_pruner_multiplier; |
| 414 | int saved_im_multiplier = classify_integer_matcher_multiplier; |
| 415 | if (prefix) { |
| 416 | // Turn off Tesseract's y-position penalties for the leading superscript. |
| 417 | classify_class_pruner_multiplier.set_value(0); |
| 418 | classify_integer_matcher_multiplier.set_value(0); |
| 419 | |
| 420 | // Adjust our expectations about the baseline for this prefix. |
| 421 | if (superscript_debug >= 3) { |
| 422 | tprintf(" recognizing first %d chopped blobs\n", num_chopped_leading); |
| 423 | } |
| 424 | recog_word_recursive(prefix); |
| 425 | if (superscript_debug >= 2) { |
| 426 | tprintf(" The leading bits look like %s %s\n", |
| 427 | ScriptPosToString(leading_pos), |
| 428 | prefix->best_choice->unichar_string().string()); |
| 429 | } |
| 430 | |
| 431 | // Restore the normal y-position penalties. |
| 432 | classify_class_pruner_multiplier.set_value(saved_cp_multiplier); |
| 433 | classify_integer_matcher_multiplier.set_value(saved_im_multiplier); |
| 434 | } |
| 435 | |
| 436 | if (superscript_debug >= 3) { |
| 437 | tprintf(" recognizing middle %d chopped blobs\n", |
| 438 | num_chopped - num_chopped_leading - num_chopped_trailing); |
| 439 | } |
nothing calls this directly
no test coverage detected