Remove unnecessary assignment and assertions

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2024-07-28 20:46:49 +02:00
parent 027ad18a8d
commit 1b222452f4

View File

@ -99,13 +99,11 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
float mean_certainty = 0.0f;
int certainty_count = 0;
PAGE_RES_IT res_it(*it_);
WERD_CHOICE *best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
WERD_CHOICE *best_choice;
switch (level) {
case RIL_BLOCK:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
@ -114,7 +112,6 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
case RIL_PARA:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
@ -124,19 +121,20 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
case RIL_TEXTLINE:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
} while (res_it.row() == res_it.prev_row());
break;
case RIL_WORD:
mean_certainty += best_choice->certainty();
++certainty_count;
best_choice = res_it.word()->best_choice;
mean_certainty = best_choice->certainty();
certainty_count = 1;
break;
case RIL_SYMBOL:
mean_certainty += best_choice->certainty(blob_index_);
++certainty_count;
best_choice = res_it.word()->best_choice;
mean_certainty = best_choice->certainty(blob_index_);
certainty_count = 1;
}
if (certainty_count > 0) {
mean_certainty /= certainty_count;
@ -320,7 +318,6 @@ char *LTRResultIterator::WordNormedUTF8Text() const {
std::string ocr_text;
WERD_CHOICE *best_choice = it_->word()->best_choice;
const UNICHARSET *unicharset = it_->word()->uch_set;
ASSERT_HOST(best_choice != nullptr);
for (unsigned i = 0; i < best_choice->length(); ++i) {
ocr_text += unicharset->get_normed_unichar(best_choice->unichar_id(i));
}