tesseract  3.05.02
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 185 of file ltrresultiterator.h.

Constructor & Destructor Documentation

◆ ChoiceIterator()

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

Definition at line 339 of file ltrresultiterator.cpp.

339  {
340  ASSERT_HOST(result_it.it_->word() != NULL);
341  word_res_ = result_it.it_->word();
342  BLOB_CHOICE_LIST* choices = NULL;
343  if (word_res_->ratings != NULL)
344  choices = word_res_->GetBlobChoices(result_it.blob_index_);
345  if (choices != NULL && !choices->empty()) {
346  choice_it_ = new BLOB_CHOICE_IT(choices);
347  choice_it_->mark_cycle_pt();
348  } else {
349  choice_it_ = NULL;
350  }
351 }
WERD * word
Definition: pageres.h:175
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ ~ChoiceIterator()

tesseract::ChoiceIterator::~ChoiceIterator ( )

Definition at line 353 of file ltrresultiterator.cpp.

353  {
354  delete choice_it_;
355 }

Member Function Documentation

◆ Confidence()

float tesseract::ChoiceIterator::Confidence ( ) const

Definition at line 377 of file ltrresultiterator.cpp.

377  {
378  if (choice_it_ == NULL)
379  return 0.0f;
380  float confidence = 100 + 5 * choice_it_->data()->certainty();
381  if (confidence < 0.0f) confidence = 0.0f;
382  if (confidence > 100.0f) confidence = 100.0f;
383  return confidence;
384 }

◆ GetUTF8Text()

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

Definition at line 368 of file ltrresultiterator.cpp.

368  {
369  if (choice_it_ == NULL)
370  return NULL;
371  UNICHAR_ID id = choice_it_->data()->unichar_id();
372  return word_res_->uch_set->id_to_unichar_ext(id);
373 }
const char * id_to_unichar_ext(UNICHAR_ID id) const
Definition: unicharset.cpp:274
const UNICHARSET * uch_set
Definition: pageres.h:192
int UNICHAR_ID
Definition: unichar.h:33

◆ Next()

bool tesseract::ChoiceIterator::Next ( )

Definition at line 359 of file ltrresultiterator.cpp.

359  {
360  if (choice_it_ == NULL)
361  return false;
362  choice_it_->forward();
363  return !choice_it_->cycled_list();
364 }

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