tesseract 4.1.1
Loading...
Searching...
No Matches
tface.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * File: tface.cpp (Formerly tface.c)
3 * Description: C side of the Tess/tessedit C/C++ interface.
4 * Author: Ray Smith
5 *
6 * (C) Copyright 1992, Hewlett-Packard Ltd.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 *
17 **********************************************************************/
18
19#include <cmath>
20
21#include "wordrec.h"
22
23#ifndef DISABLED_LEGACY_ENGINE
24#include "callcpp.h"
25#include "chop.h"
26#include "featdefs.h"
27#include "pageres.h"
28#include "params_model.h"
29#endif
30
31namespace tesseract {
32
40void Wordrec::program_editup(const char *textbase,
41 TessdataManager *init_classifier,
42 TessdataManager *init_dict) {
43 if (textbase != nullptr) imagefile = textbase;
44#ifndef DISABLED_LEGACY_ENGINE
46 InitAdaptiveClassifier(init_classifier);
47 if (init_dict) {
49 getDict().Load(lang, init_dict);
51 }
53#endif // ndef DISABLED_LEGACY_ENGINE
54}
55
56
64
65 return (0);
66}
67
68
75void Wordrec::program_editdown(int32_t elasped_time) {
76#ifndef DISABLED_LEGACY_ENGINE
78#endif // ndef DISABLED_LEGACY_ENGINE
79 getDict().End();
80}
81
82
90 return getDict().valid_word(word);
91}
92
93
94#ifndef DISABLED_LEGACY_ENGINE
95
102 chop_ok_split.set_value(70.0);
103 language_model_->getParamsModel().SetPass(ParamsModel::PTRAIN_PASS1);
104 SettupPass1();
105}
106
107
114 chop_ok_split.set_value(pass2_ok_split);
115 language_model_->getParamsModel().SetPass(ParamsModel::PTRAIN_PASS2);
116 SettupPass2();
117}
118
119
127 chop_word_main(word);
128 word->DebugWordChoices(getDict().stopper_debug_level >= 1,
129 getDict().word_to_debug.string());
131}
132
133
140BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *tessblob) {
141 // Rotate the blob for classification if necessary.
142 TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded();
143 if (rotated_blob == nullptr) {
144 rotated_blob = tessblob;
145 }
146 auto *ratings = new BLOB_CHOICE_LIST(); // matcher result
147 AdaptiveClassifier(rotated_blob, ratings);
148 if (rotated_blob != tessblob) {
149 delete rotated_blob;
150 }
151 return ratings;
152}
153
154#endif // ndef DISABLED_LEGACY_ENGINE
155
156} // namespace tesseract
@ W_EOL
end of line
Definition: werd.h:33
#define ASSERT_HOST(x)
Definition: errcode.h:88
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:112
Definition: blobs.h:284
TBLOB * ClassifyNormalizeIfNeeded() const
Definition: blobs.cpp:346
void DebugWordChoices(bool debug, const char *word_to_debug)
Definition: pageres.cpp:480
bool StatesAllValid()
Definition: pageres.cpp:458
WERD * word
Definition: pageres.h:186
bool flag(WERD_FLAGS mask) const
Definition: werd.h:117
STRING imagefile
Definition: ccutil.h:77
STRING lang
Definition: ccutil.h:71
FEATURE_DEFS_STRUCT feature_defs_
Definition: classify.h:541
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:191
void InitAdaptiveClassifier(TessdataManager *mgr)
Definition: adaptmatch.cpp:527
void EndAdaptiveClassifier()
Definition: adaptmatch.cpp:459
virtual Dict & getDict()
Definition: classify.h:107
static TESS_API DawgCache * GlobalDawgCache()
Definition: dict.cpp:184
void reset_hyphen_vars(bool last_word_on_line)
Definition: hyphen.cpp:28
int valid_word(const WERD_CHOICE &word, bool numbers_ok) const
Definition: dict.cpp:778
void SetupForLoad(DawgCache *dawg_cache)
Definition: dict.cpp:192
void End()
Definition: dict.cpp:372
bool FinishLoad()
Definition: dict.cpp:351
void Load(const STRING &lang, TessdataManager *data_file)
Definition: dict.cpp:210
int dict_word(const WERD_CHOICE &word)
Definition: tface.cpp:89
void set_pass1()
Definition: tface.cpp:101
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:140
void program_editdown(int32_t elasped_time)
Definition: tface.cpp:75
void program_editup(const char *textbase, TessdataManager *init_classifier, TessdataManager *init_dict)
Definition: tface.cpp:40
void chop_word_main(WERD_RES *word)
Definition: chopper.cpp:391
PRIORITY pass2_ok_split
Definition: wordrec.h:472
void set_pass2()
Definition: tface.cpp:113
double chop_ok_split
Definition: wordrec.h:221
void cc_recog(WERD_RES *word)
Definition: tface.cpp:125
std::unique_ptr< LanguageModel > language_model_
Definition: wordrec.h:471