Skip to content

Commit

Permalink
Merge pull request tesseract-ocr#2673 from noahmetzger/LSTMChoiceRIL
Browse files Browse the repository at this point in the history
Fixed minor bug in ChoiceIterator when lstm_choice_mode isn't active.
  • Loading branch information
zdenop committed Sep 24, 2019
2 parents cb0c024 + ff4c1d2 commit b5c1fcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ccmain/ltrresultiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ ChoiceIterator::ChoiceIterator(const LTRResultIterator& result_it) {
word_res_ = result_it.it_->word();
oemLSTM_ = word_res_->tesseract->AnyLSTMLang();
oemLegacy_ = word_res_->tesseract->AnyTessLang();
lstm_choice_mode_ = word_res_->tesseract->lstm_choice_mode;
rating_coefficient_ = word_res_->tesseract->lstm_rating_coefficient;
blanks_before_word_ = result_it.BlanksBeforeWord();
BLOB_CHOICE_LIST* choices = nullptr;
Expand All @@ -393,7 +394,7 @@ ChoiceIterator::ChoiceIterator(const LTRResultIterator& result_it) {
filterSpaces();
}
}
if (oemLegacy_ && word_res_->ratings != nullptr)
if ((oemLegacy_ || !lstm_choice_mode_) && word_res_->ratings != nullptr)
choices = word_res_->GetBlobChoices(result_it.blob_index_);
if (choices != nullptr && !choices->empty()) {
choice_it_ = new BLOB_CHOICE_IT(choices);
Expand Down
2 changes: 2 additions & 0 deletions src/ccmain/ltrresultiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class ChoiceIterator {
bool oemLSTM_;
// true when there is legacy engine related trained data
bool oemLegacy_;
// true when lstm_choice_mode is activated
bool lstm_choice_mode_;
// regulates the rating granularity
double rating_coefficient_;
// leading blanks
Expand Down

0 comments on commit b5c1fcc

Please sign in to comment.