tesseract  4.00.00dev
tface.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: tface.c (Formerly tface.c)
3  * Description: C side of the Tess/tessedit C/C++ interface.
4  * Author: Ray Smith
5  * Created: Mon Apr 27 11:57:06 BST 1992
6  *
7  * (C) Copyright 1992, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #include "callcpp.h"
21 #include "chop.h"
22 #include "chopper.h"
23 #include "danerror.h"
24 #include "globals.h"
25 #include "gradechop.h"
26 #include "pageres.h"
27 #include "wordrec.h"
28 #include "featdefs.h"
29 #include "params_model.h"
30 
31 #include <math.h>
32 #ifdef __UNIX__
33 #include <unistd.h>
34 #endif
35 
36 
37 namespace tesseract {
38 
46 void Wordrec::program_editup(const char *textbase,
47  TessdataManager *init_classifier,
48  TessdataManager *init_dict) {
49  if (textbase != NULL) imagefile = textbase;
51  InitAdaptiveClassifier(init_classifier);
52  if (init_dict) {
54  getDict().Load(lang, init_dict);
55  getDict().FinishLoad();
56  }
58 }
59 
66  program_editdown (0);
67 
68  return (0);
69 }
70 
71 
78 void Wordrec::program_editdown(inT32 elasped_time) {
80  getDict().End();
81 }
82 
83 
90  chop_ok_split.set_value(70.0);
92  SettupPass1();
93 }
94 
95 
102  chop_ok_split.set_value(pass2_ok_split);
104  SettupPass2();
105 }
106 
107 
115  chop_word_main(word);
116  word->DebugWordChoices(getDict().stopper_debug_level >= 1,
117  getDict().word_to_debug.string());
118  ASSERT_HOST(word->StatesAllValid());
119 }
120 
121 
128 int Wordrec::dict_word(const WERD_CHOICE &word) {
129  return getDict().valid_word(word);
130 }
131 
138 BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *tessblob) {
139  // Rotate the blob for classification if necessary.
140  TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded();
141  if (rotated_blob == NULL) {
142  rotated_blob = tessblob;
143  }
144  BLOB_CHOICE_LIST *ratings = new BLOB_CHOICE_LIST(); // matcher result
145  AdaptiveClassifier(rotated_blob, ratings);
146  if (rotated_blob != tessblob) {
147  delete rotated_blob;
148  }
149  return ratings;
150 }
151 
152 
153 } // namespace tesseract
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:121
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:138
int32_t inT32
Definition: host.h:38
Dict & getDict()
Definition: classify.h:65
double chop_ok_split
Definition: wordrec.h:156
Definition: werd.h:36
FEATURE_DEFS_STRUCT feature_defs_
Definition: classify.h:506
bool StatesAllValid()
Definition: pageres.cpp:450
PRIORITY pass2_ok_split
Definition: wordrec.h:411
void chop_word_main(WERD_RES *word)
Definition: chopper.cpp:393
#define ASSERT_HOST(x)
Definition: errcode.h:84
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128
STRING lang
Definition: ccutil.h:66
void set_pass1()
Definition: tface.cpp:89
void program_editdown(inT32 elasped_time)
Definition: tface.cpp:78
void program_editup(const char *textbase, TessdataManager *init_classifier, TessdataManager *init_dict)
Definition: tface.cpp:46
void reset_hyphen_vars(bool last_word_on_line)
Definition: hyphen.cpp:32
TBLOB * ClassifyNormalizeIfNeeded() const
Definition: blobs.cpp:363
ParamsModel & getParamsModel()
int valid_word(const WERD_CHOICE &word, bool numbers_ok) const
Definition: dict.cpp:750
void EndAdaptiveClassifier()
Definition: adaptmatch.cpp:456
STRING imagefile
Definition: ccutil.h:70
void End()
Definition: dict.cpp:347
Definition: blobs.h:261
WERD * word
Definition: pageres.h:175
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:185
int dict_word(const WERD_CHOICE &word)
Definition: tface.cpp:128
void InitAdaptiveClassifier(TessdataManager *mgr)
Definition: adaptmatch.cpp:527
void set_pass2()
Definition: tface.cpp:101
static DawgCache * GlobalDawgCache()
Definition: dict.cpp:198
LanguageModel * language_model_
Definition: wordrec.h:410
void DebugWordChoices(bool debug, const char *word_to_debug)
Definition: pageres.cpp:472
void SetupForLoad(DawgCache *dawg_cache)
Definition: dict.cpp:206
void Load(const STRING &lang, TessdataManager *data_file)
Definition: dict.cpp:224
void cc_recog(WERD_RES *word)
Definition: tface.cpp:113
bool FinishLoad()
Definition: dict.cpp:327
void SetPass(PassEnum pass)
Definition: params_model.h:72