tesseract  4.0.0-1-g2a2b
tesseract::ChoiceIterator Class Reference

#include <ltrresultiterator.h>

Public Member Functions

 ChoiceIterator (const LTRResultIterator &result_it)
 
 ~ChoiceIterator ()
 
bool Next ()
 
const char * GetUTF8Text () const
 
float Confidence () const
 

Detailed Description

Definition at line 191 of file ltrresultiterator.h.

Constructor & Destructor Documentation

◆ ChoiceIterator()

tesseract::ChoiceIterator::ChoiceIterator ( const LTRResultIterator result_it)
explicit

Definition at line 347 of file ltrresultiterator.cpp.

347  {
348  ASSERT_HOST(result_it.it_->word() != nullptr);
349  word_res_ = result_it.it_->word();
350  BLOB_CHOICE_LIST* choices = nullptr;
351  if (word_res_->ratings != nullptr)
352  choices = word_res_->GetBlobChoices(result_it.blob_index_);
353  if (choices != nullptr && !choices->empty()) {
354  choice_it_ = new BLOB_CHOICE_IT(choices);
355  choice_it_->mark_cycle_pt();
356  } else {
357  choice_it_ = nullptr;
358  }
359 }
#define ASSERT_HOST(x)
Definition: errcode.h:84
WERD * word
Definition: pageres.h:189

◆ ~ChoiceIterator()

tesseract::ChoiceIterator::~ChoiceIterator ( )

Definition at line 361 of file ltrresultiterator.cpp.

361  {
362  delete choice_it_;
363 }

Member Function Documentation

◆ Confidence()

float tesseract::ChoiceIterator::Confidence ( ) const

Definition at line 385 of file ltrresultiterator.cpp.

385  {
386  if (choice_it_ == nullptr)
387  return 0.0f;
388  float confidence = 100 + 5 * choice_it_->data()->certainty();
389  if (confidence < 0.0f) confidence = 0.0f;
390  if (confidence > 100.0f) confidence = 100.0f;
391  return confidence;
392 }

◆ GetUTF8Text()

const char * tesseract::ChoiceIterator::GetUTF8Text ( ) const

Definition at line 376 of file ltrresultiterator.cpp.

376  {
377  if (choice_it_ == nullptr)
378  return nullptr;
379  UNICHAR_ID id = choice_it_->data()->unichar_id();
380  return word_res_->uch_set->id_to_unichar_ext(id);
381 }
int UNICHAR_ID
Definition: unichar.h:35
const char * id_to_unichar_ext(UNICHAR_ID id) const
Definition: unicharset.cpp:298
const UNICHARSET * uch_set
Definition: pageres.h:206

◆ Next()

bool tesseract::ChoiceIterator::Next ( )

Definition at line 367 of file ltrresultiterator.cpp.

367  {
368  if (choice_it_ == nullptr)
369  return false;
370  choice_it_->forward();
371  return !choice_it_->cycled_list();
372 }

The documentation for this class was generated from the following files: