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

Function CorrectRepcharChoices

deps/tesseract/ccmain/control.cpp:1604–1620  ·  view source on GitHub ↗

Helper to insert blob_choice in each location in the leader word if there is no matching BLOB_CHOICE there already, and correct any incorrect results in the best_choice.

Source from the content-addressed store, hash-verified

1602// no matching BLOB_CHOICE there already, and correct any incorrect results
1603// in the best_choice.
1604static void CorrectRepcharChoices(BLOB_CHOICE* blob_choice,
1605 WERD_RES* word_res) {
1606 WERD_CHOICE* word = word_res->best_choice;
1607 for (int i = 0; i < word_res->best_choice->length(); ++i) {
1608 BLOB_CHOICE* choice = FindMatchingChoice(blob_choice->unichar_id(),
1609 word_res->GetBlobChoices(i));
1610 if (choice == NULL) {
1611 BLOB_CHOICE_IT choice_it(word_res->GetBlobChoices(i));
1612 choice_it.add_before_stay_put(new BLOB_CHOICE(*blob_choice));
1613 }
1614 }
1615 // Correct any incorrect results in word.
1616 for (int i = 0; i < word->length(); ++i) {
1617 if (word->unichar_id(i) != blob_choice->unichar_id())
1618 word->set_unichar_id(blob_choice->unichar_id(), i);
1619 }
1620}
1621
1622/**
1623 * fix_rep_char()

Callers 1

fix_rep_charMethod · 0.85

Calls 6

FindMatchingChoiceFunction · 0.85
unichar_idMethod · 0.80
GetBlobChoicesMethod · 0.80
set_unichar_idMethod · 0.80
lengthMethod · 0.45
add_before_stay_putMethod · 0.45

Tested by

no test coverage detected