Repository: tesseract-ocr/tesseract
File: src/ccmain/control.cpp (C++)

Code before:
      ? word_data.prev_word->word->best_choice : nullptr;
#ifndef ANDROID_BUILD
#ifdef DISABLED_LEGACY_ENGINE
  if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
#else
  if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY ||
      tessedit_ocr_engine_mode == OEM_TESSERACT_LSTM_COMBINED) {
#endif  // def DISABLED_LEGACY_ENGINE
    if (!(*in_word)->odd_size || tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
      LSTMRecognizeWord(*block, row, *in_word, out_words);
      if (!out_words->empty())
        return;  // Successful lstm recognition.
    }
    if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
      // No fallback allowed, so use a fake.
      (*in_word)->SetupFake(lstm_recognizer_->GetUnicharset());
      return;
    }

  #ifndef DISABLED_LEGACY_ENGINE
    // Fall back to tesseract for failed words or odd words.
    (*in_word)->SetupForRecognition(unicharset, this, BestPix(),
                                    OEM_TESSERACT_ONLY, nullptr,
                                    classify_bln_numeric_mode,
                                    textord_use_cjk_fp_model,
                                    poly_allow_detailed_fx, row, block);
#endif  // ndef DISABLED_LEGACY_ENGINE
  }
#endif  // ndef ANDROID_BUILD

#ifndef DISABLED_LEGACY_ENGINE
  WERD_RES* word = *in_word;
  match_word_pass_n(1, word, row, block);
  if (!word->tess_failed && !word->word->flag(W_REP_CHAR)) {
    word->tess_would_adapt = AdaptableWord(word);
    bool adapt_ok = word_adaptable(word, tessedit_tess_adaption_mode);

    if (adapt_ok) {
      // Send word to adaptive classifier for training.
      word->BestChoiceToCorrectText();
      LearnWord(nullptr, word);
      // Mark misadaptions if running blamer.
      if (word->blamer_bundle != nullptr) {
        word->blamer_bundle->SetMisAdaptionDebug(word->best_choice,
                                                 wordrec_debug_blamer);
      }
    }

    if (tessedit_enable_doc_dict && !word->IsAmbiguous())
      tess_add_doc_word(word->best_choice);
  }

Review comment (suggestion):
```suggestion
#endif  // ndef DISABLED_LEGACY_ENGINE
```

Code after:
      ? word_data.prev_word->word->best_choice : nullptr;
#ifdef DISABLED_LEGACY_ENGINE
  if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
#else
  if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY ||
      tessedit_ocr_engine_mode == OEM_TESSERACT_LSTM_COMBINED) {
#endif  // def DISABLED_LEGACY_ENGINE
    if (!(*in_word)->odd_size || tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
      LSTMRecognizeWord(*block, row, *in_word, out_words);
      if (!out_words->empty())
        return;  // Successful lstm recognition.
    }
    if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY) {
      // No fallback allowed, so use a fake.
      (*in_word)->SetupFake(lstm_recognizer_->GetUnicharset());
      return;
    }

  #ifndef DISABLED_LEGACY_ENGINE
    // Fall back to tesseract for failed words or odd words.
    (*in_word)->SetupForRecognition(unicharset, this, BestPix(),
                                    OEM_TESSERACT_ONLY, nullptr,
                                    classify_bln_numeric_mode,
                                    textord_use_cjk_fp_model,
                                    poly_allow_detailed_fx, row, block);
  #endif  // ndef DISABLED_LEGACY_ENGINE
  }

#ifndef DISABLED_LEGACY_ENGINE
  WERD_RES* word = *in_word;
  match_word_pass_n(1, word, row, block);
  if (!word->tess_failed && !word->word->flag(W_REP_CHAR)) {
    word->tess_would_adapt = AdaptableWord(word);
    bool adapt_ok = word_adaptable(word, tessedit_tess_adaption_mode);

    if (adapt_ok) {
      // Send word to adaptive classifier for training.
      word->BestChoiceToCorrectText();
      LearnWord(nullptr, word);
      // Mark misadaptions if running blamer.
      if (word->blamer_bundle != nullptr) {
        word->blamer_bundle->SetMisAdaptionDebug(word->best_choice,
                                                 wordrec_debug_blamer);
      }
    }

    if (tessedit_enable_doc_dict && !word->IsAmbiguous())
      tess_add_doc_word(word->best_choice);
  }
#endif  // ndef DISABLED_LEGACY_ENGINE
}