All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::CubeRecoContext Class Reference

#include <cube_reco_context.h>

Public Types

enum  ReadOrder { L2R, R2L }
 

Public Member Functions

 CubeRecoContext (Tesseract *tess_obj)
 
 ~CubeRecoContext ()
 
const string & Lang () const
 
CharSetCharacterSet () const
 
const UNICHARSETTessUnicharset () const
 
CharClassifierClassifier () const
 
WordSizeModelSizeModel () const
 
CharBigramsBigrams () const
 
WordUnigramsWordUnigramsObj () const
 
TuningParamsParams () const
 
LangModelLangMod () const
 
ReadOrder ReadingOrder () const
 
bool HasCase () const
 
bool Cursive () const
 
bool HasItalics () const
 
bool Contextual () const
 
bool SizeNormalization () const
 
bool NoisyInput () const
 
bool OOD () const
 
bool Numeric () const
 
bool WordList () const
 
bool Punc () const
 
bool CaseSensitive () const
 
void SetSizeNormalization (bool size_normalization)
 
void SetNoisyInput (bool noisy_input)
 
void SetOOD (bool ood_enabled)
 
void SetNumeric (bool numeric_enabled)
 
void SetWordList (bool word_list_enabled)
 
void SetPunc (bool punc_enabled)
 
void SetCaseSensitive (bool case_sensitive)
 
tesseract::TesseractTesseractObject () const
 
bool GetDataFilePath (string *path) const
 

Static Public Member Functions

static CubeRecoContextCreate (Tesseract *tess_obj, TessdataManager *tessdata_manager, UNICHARSET *tess_unicharset)
 

Detailed Description

Definition at line 43 of file cube_reco_context.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

tesseract::CubeRecoContext::CubeRecoContext ( Tesseract tess_obj)

Instantiate a CubeRecoContext object using a Tesseract object. CubeRecoContext will not take ownership of tess_obj, but will record the pointer to it and will make use of various Tesseract components (language model, flags, etc). Thus the caller should keep tess_obj alive so long as the instantiated CubeRecoContext is used.

Definition at line 42 of file cube_reco_context.cpp.

42  {
43  tess_obj_ = tess_obj;
44  lang_ = "";
45  loaded_ = false;
46  lang_mod_ = NULL;
47  params_ = NULL;
48  char_classifier_ = NULL;
49  char_set_ = NULL;
50  word_size_model_ = NULL;
51  char_bigrams_ = NULL;
52  word_unigrams_ = NULL;
53  noisy_input_ = false;
54  size_normalization_ = false;
55 }
#define NULL
Definition: host.h:144
tesseract::CubeRecoContext::~CubeRecoContext ( )

Definition at line 57 of file cube_reco_context.cpp.

57  {
58  if (char_classifier_ != NULL) {
59  delete char_classifier_;
60  char_classifier_ = NULL;
61  }
62 
63  if (word_size_model_ != NULL) {
64  delete word_size_model_;
65  word_size_model_ = NULL;
66  }
67 
68  if (char_set_ != NULL) {
69  delete char_set_;
70  char_set_ = NULL;
71  }
72 
73  if (char_bigrams_ != NULL) {
74  delete char_bigrams_;
75  char_bigrams_ = NULL;
76  }
77 
78  if (word_unigrams_ != NULL) {
79  delete word_unigrams_;
80  word_unigrams_ = NULL;
81  }
82 
83  if (lang_mod_ != NULL) {
84  delete lang_mod_;
85  lang_mod_ = NULL;
86  }
87 
88  if (params_ != NULL) {
89  delete params_;
90  params_ = NULL;
91  }
92 }
#define NULL
Definition: host.h:144

Member Function Documentation

CharBigrams* tesseract::CubeRecoContext::Bigrams ( ) const
inline

Definition at line 62 of file cube_reco_context.h.

62 { return char_bigrams_; }
bool tesseract::CubeRecoContext::CaseSensitive ( ) const
inline

Definition at line 96 of file cube_reco_context.h.

96  {
97  return char_classifier_->CaseSensitive();
98  }
CharSet* tesseract::CubeRecoContext::CharacterSet ( ) const
inline

Definition at line 58 of file cube_reco_context.h.

58 { return char_set_; }
CharClassifier* tesseract::CubeRecoContext::Classifier ( ) const
inline

Definition at line 60 of file cube_reco_context.h.

60 { return char_classifier_; }
bool tesseract::CubeRecoContext::Contextual ( ) const
inline

Definition at line 85 of file cube_reco_context.h.

85  {
86  return (lang_ == "ara");
87  }
CubeRecoContext * tesseract::CubeRecoContext::Create ( Tesseract tess_obj,
TessdataManager tessdata_manager,
UNICHARSET tess_unicharset 
)
static

Creates a CubeRecoContext object using a tesseract object

Definition at line 188 of file cube_reco_context.cpp.

190  {
191  // create the object
192  CubeRecoContext *cntxt = new CubeRecoContext(tess_obj);
193  if (cntxt == NULL) {
194  fprintf(stderr, "Cube ERROR (CubeRecoContext::Create): unable to create "
195  "CubeRecoContext object\n");
196  return NULL;
197  }
198  // load the necessary components
199  if (cntxt->Load(tessdata_manager, tess_unicharset) == false) {
200  fprintf(stderr, "Cube ERROR (CubeRecoContext::Create): unable to init "
201  "CubeRecoContext object\n");
202  delete cntxt;
203  return NULL;
204  }
205  // success
206  return cntxt;
207 }
CubeRecoContext(Tesseract *tess_obj)
#define NULL
Definition: host.h:144
bool tesseract::CubeRecoContext::Cursive ( ) const
inline

Definition at line 77 of file cube_reco_context.h.

77  {
78  return (lang_ == "ara");
79  }
bool tesseract::CubeRecoContext::GetDataFilePath ( string *  path) const

Returns the path of the data files by looking up the TESSDATA_PREFIX environment variable and appending a "tessdata" directory to it

Definition at line 98 of file cube_reco_context.cpp.

98  {
99  *path = tess_obj_->datadir.string();
100  return true;
101 }
STRING datadir
Definition: ccutil.h:67
const char * string() const
Definition: strngs.cpp:193
bool tesseract::CubeRecoContext::HasCase ( ) const
inline

Definition at line 73 of file cube_reco_context.h.

73  {
74  return (lang_ != "ara" && lang_ != "hin");
75  }
bool tesseract::CubeRecoContext::HasItalics ( ) const
inline

Definition at line 81 of file cube_reco_context.h.

81  {
82  return (lang_ != "ara" && lang_ != "hin");
83  }
const string& tesseract::CubeRecoContext::Lang ( ) const
inline

Definition at line 57 of file cube_reco_context.h.

57 { return lang_; }
LangModel* tesseract::CubeRecoContext::LangMod ( ) const
inline

Definition at line 65 of file cube_reco_context.h.

65 { return lang_mod_; }
bool tesseract::CubeRecoContext::NoisyInput ( ) const
inline

Definition at line 91 of file cube_reco_context.h.

91 { return noisy_input_; }
bool tesseract::CubeRecoContext::Numeric ( ) const
inline

Definition at line 93 of file cube_reco_context.h.

93 { return lang_mod_->Numeric(); }
bool tesseract::CubeRecoContext::OOD ( ) const
inline

Definition at line 92 of file cube_reco_context.h.

92 { return lang_mod_->OOD(); }
TuningParams* tesseract::CubeRecoContext::Params ( ) const
inline

Definition at line 64 of file cube_reco_context.h.

64 { return params_; }
bool tesseract::CubeRecoContext::Punc ( ) const
inline

Definition at line 95 of file cube_reco_context.h.

95 { return lang_mod_->Punc(); }
ReadOrder tesseract::CubeRecoContext::ReadingOrder ( ) const
inline

Definition at line 68 of file cube_reco_context.h.

68  {
69  return ((lang_ == "ara") ? R2L : L2R);
70  }
void tesseract::CubeRecoContext::SetCaseSensitive ( bool  case_sensitive)
inline

Definition at line 118 of file cube_reco_context.h.

118  {
119  char_classifier_->SetCaseSensitive(case_sensitive);
120  }
void SetCaseSensitive(bool case_sensitive)
void tesseract::CubeRecoContext::SetNoisyInput ( bool  noisy_input)
inline

Definition at line 103 of file cube_reco_context.h.

103  {
104  noisy_input_ = noisy_input;
105  }
void tesseract::CubeRecoContext::SetNumeric ( bool  numeric_enabled)
inline

Definition at line 109 of file cube_reco_context.h.

109  {
110  lang_mod_->SetNumeric(numeric_enabled);
111  }
void SetNumeric(bool numeric)
Definition: lang_model.h:66
void tesseract::CubeRecoContext::SetOOD ( bool  ood_enabled)
inline

Definition at line 106 of file cube_reco_context.h.

106  {
107  lang_mod_->SetOOD(ood_enabled);
108  }
void SetOOD(bool ood)
Definition: lang_model.h:65
void tesseract::CubeRecoContext::SetPunc ( bool  punc_enabled)
inline

Definition at line 115 of file cube_reco_context.h.

115  {
116  lang_mod_->SetPunc(punc_enabled);
117  }
void SetPunc(bool punc_enabled)
Definition: lang_model.h:68
void tesseract::CubeRecoContext::SetSizeNormalization ( bool  size_normalization)
inline

Definition at line 100 of file cube_reco_context.h.

100  {
101  size_normalization_ = size_normalization;
102  }
void tesseract::CubeRecoContext::SetWordList ( bool  word_list_enabled)
inline

Definition at line 112 of file cube_reco_context.h.

112  {
113  lang_mod_->SetWordList(word_list_enabled);
114  }
void SetWordList(bool word_list)
Definition: lang_model.h:67
WordSizeModel* tesseract::CubeRecoContext::SizeModel ( ) const
inline

Definition at line 61 of file cube_reco_context.h.

61 { return word_size_model_; }
bool tesseract::CubeRecoContext::SizeNormalization ( ) const
inline

Definition at line 90 of file cube_reco_context.h.

90 { return size_normalization_; }
tesseract::Tesseract* tesseract::CubeRecoContext::TesseractObject ( ) const
inline

Definition at line 121 of file cube_reco_context.h.

121  {
122  return tess_obj_;
123  }
const UNICHARSET* tesseract::CubeRecoContext::TessUnicharset ( ) const
inline

Definition at line 59 of file cube_reco_context.h.

59 { return tess_unicharset_; }
bool tesseract::CubeRecoContext::WordList ( ) const
inline

Definition at line 94 of file cube_reco_context.h.

94 { return lang_mod_->WordList(); }
WordUnigrams* tesseract::CubeRecoContext::WordUnigramsObj ( ) const
inline

Definition at line 63 of file cube_reco_context.h.

63 { return word_unigrams_; }

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