tesseract  3.03
tesseract::ViterbiStateEntry Struct Reference

#include <lm_state.h>

Inheritance diagram for tesseract::ViterbiStateEntry:
ELIST_LINK

List of all members.

Public Member Functions

 ViterbiStateEntry (ViterbiStateEntry *pe, BLOB_CHOICE *b, float c, float ol, const LMConsistencyInfo &ci, const AssociateStats &as, LanguageModelFlagsType tcf, LanguageModelDawgInfo *d, LanguageModelNgramInfo *n, const char *debug_uch)
 ~ViterbiStateEntry ()
bool Consistent () const
bool HasAlnumChoice (const UNICHARSET &unicharset)
void Print (const char *msg) const

Static Public Member Functions

static int Compare (const void *e1, const void *e2)

Public Attributes

float cost
BLOB_CHOICEcurr_b
ViterbiStateEntryparent_vse
ViterbiStateEntrycompeting_vse
float ratings_sum
float min_certainty
int adapted
int length
float outline_length
LMConsistencyInfo consistency_info
AssociateStats associate_stats
LanguageModelFlagsType top_choice_flags
LanguageModelDawgInfodawg_info
LanguageModelNgramInfongram_info
bool updated
STRINGdebug_str

Detailed Description

Definition at line 92 of file lm_state.h.


Constructor & Destructor Documentation

tesseract::ViterbiStateEntry::ViterbiStateEntry ( ViterbiStateEntry pe,
BLOB_CHOICE b,
float  c,
float  ol,
const LMConsistencyInfo ci,
const AssociateStats as,
LanguageModelFlagsType  tcf,
LanguageModelDawgInfo d,
LanguageModelNgramInfo n,
const char *  debug_uch 
) [inline]

Definition at line 93 of file lm_state.h.

    : cost(c), curr_b(b), parent_vse(pe), competing_vse(NULL),
      ratings_sum(b->rating()),
      min_certainty(b->certainty()), adapted(b->IsAdapted()), length(1),
      outline_length(ol), consistency_info(ci), associate_stats(as),
      top_choice_flags(tcf), dawg_info(d), ngram_info(n),
      updated(true) {
    debug_str = (debug_uch == NULL) ? NULL : new STRING();
    if (pe != NULL) {
      ratings_sum += pe->ratings_sum;
      if (pe->min_certainty < min_certainty) {
        min_certainty = pe->min_certainty;
      }
      adapted += pe->adapted;
      length += pe->length;
      outline_length += pe->outline_length;
      if (debug_uch != NULL) *debug_str += *(pe->debug_str);
    }
    if (debug_str != NULL && debug_uch != NULL) *debug_str += debug_uch;
  }

Definition at line 120 of file lm_state.h.

                       {
    delete dawg_info;
    delete ngram_info;
    delete debug_str;
  }

Member Function Documentation

static int tesseract::ViterbiStateEntry::Compare ( const void *  e1,
const void *  e2 
) [inline, static]

Definition at line 127 of file lm_state.h.

                                                     {
    const ViterbiStateEntry *ve1 =
      *reinterpret_cast<const ViterbiStateEntry * const *>(e1);
    const ViterbiStateEntry *ve2 =
      *reinterpret_cast<const ViterbiStateEntry * const *>(e2);
    return (ve1->cost < ve2->cost) ? -1 : 1;
  }

Definition at line 134 of file lm_state.h.

                                 {
    if (dawg_info != NULL && consistency_info.NumInconsistentCase() == 0) {
      return true;
    }
    return consistency_info.Consistent();
  }
bool tesseract::ViterbiStateEntry::HasAlnumChoice ( const UNICHARSET unicharset) [inline]

Definition at line 142 of file lm_state.h.

                                                    {
    if (curr_b == NULL) return false;
    UNICHAR_ID unichar_id =  curr_b->unichar_id();
    if (unicharset.get_isalpha(unichar_id) ||
        unicharset.get_isdigit(unichar_id))
      return true;
    return false;
  }
void tesseract::ViterbiStateEntry::Print ( const char *  msg) const

Definition at line 27 of file lm_state.cpp.

                                                   {
  tprintf("%s ViterbiStateEntry", msg);
  if (updated) tprintf("(NEW)");
  if (this->debug_str != NULL) {
    tprintf(" str=%s", this->debug_str->string());
  }
  tprintf(" with ratings_sum=%.4f length=%d cost=%.6f",
          this->ratings_sum, this->length, this->cost);
  if (this->top_choice_flags) {
    tprintf(" top_choice_flags=0x%x", this->top_choice_flags);
  }
  if (!this->Consistent()) {
    tprintf(" inconsistent=(punc %d case %d chartype %d script %d font %d)",
            this->consistency_info.NumInconsistentPunc(),
            this->consistency_info.NumInconsistentCase(),
            this->consistency_info.NumInconsistentChartype(),
            this->consistency_info.inconsistent_script,
            this->consistency_info.inconsistent_font);
  }
  if (this->dawg_info) tprintf(" permuter=%d", this->dawg_info->permuter);
  if (this->ngram_info) {
    tprintf(" ngram_cl_cost=%g context=%s ngram pruned=%d",
            this->ngram_info->ngram_and_classifier_cost,
            this->ngram_info->context.string(),
            this->ngram_info->pruned);
  }
  if (this->associate_stats.shape_cost > 0.0f) {
    tprintf(" shape_cost=%g", this->associate_stats.shape_cost);
  }
  tprintf(" %s",
          XHeightConsistencyEnumName[this->consistency_info.xht_decision]);

  tprintf("\n");
}

Member Data Documentation

Definition at line 167 of file lm_state.h.

Definition at line 154 of file lm_state.h.

Definition at line 168 of file lm_state.h.

Definition at line 166 of file lm_state.h.

Definition at line 169 of file lm_state.h.

Definition at line 165 of file lm_state.h.

Definition at line 185 of file lm_state.h.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines