tesseract  5.0.0-alpha-619-ge9db
tessbox.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: tessbox.cpp (Formerly tessbox.c)
3  * Description: Black boxed Tess for developing a resaljet.
4  * Author: Ray Smith
5  * Created: Thu Apr 23 11:03:36 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 "mfoutline.h"
21 #include "tesseractclass.h"
22 
31 namespace tesseract {
32 void Tesseract::tess_segment_pass_n(int pass_n, WERD_RES *word) {
33  int saved_enable_assoc = 0;
34  int saved_chop_enable = 0;
35 
36  if (word->word->flag(W_DONT_CHOP)) {
37  saved_enable_assoc = wordrec_enable_assoc;
38  saved_chop_enable = chop_enable;
39  wordrec_enable_assoc.set_value(0);
40  chop_enable.set_value(0);
41  }
42  if (pass_n == 1)
43  set_pass1();
44  else
45  set_pass2();
46  recog_word(word);
47  if (word->best_choice == nullptr)
48  word->SetupFake(*word->uch_set);
49  if (word->word->flag(W_DONT_CHOP)) {
50  wordrec_enable_assoc.set_value(saved_enable_assoc);
51  chop_enable.set_value(saved_chop_enable);
52  }
53 }
54 
63  return getDict().AcceptableResult(word);
64 }
65 
66 
72 void Tesseract::tess_add_doc_word(WERD_CHOICE *word_choice) {
73  getDict().add_document_word(*word_choice);
74 }
75 } // namespace tesseract
WERD::flag
bool flag(WERD_FLAGS mask) const
Definition: werd.h:116
WERD_CHOICE
Definition: ratngs.h:261
W_DONT_CHOP
fixed pitch chopped
Definition: werd.h:51
tesseractclass.h
tesseract::Tesseract::recog_word
void recog_word(WERD_RES *word)
Definition: tfacepp.cpp:41
mfoutline.h
tesseract::Wordrec::set_pass1
void set_pass1()
Definition: tface.cpp:115
WERD_RES
Definition: pageres.h:160
tesseract::Dict::add_document_word
void add_document_word(const WERD_CHOICE &best_choice)
Adds a word found on this document to the document specific dictionary.
Definition: dict.cpp:644
tesseract::Tesseract::tess_add_doc_word
void tess_add_doc_word(WERD_CHOICE *word_choice)
Definition: tessbox.cpp:71
WERD_RES::uch_set
const UNICHARSET * uch_set
Definition: pageres.h:197
tesseract::Dict::AcceptableResult
bool AcceptableResult(WERD_RES *word) const
Definition: stopper.cpp:116
tesseract::Wordrec::wordrec_enable_assoc
bool wordrec_enable_assoc
Definition: wordrec.h:198
WERD_RES::best_choice
WERD_CHOICE * best_choice
Definition: pageres.h:235
tesseract::Wordrec::chop_enable
bool chop_enable
Definition: wordrec.h:205
tesseract::Tesseract::getDict
Dict & getDict() override
Definition: tesseractclass.cpp:564
tesseract::Tesseract::tess_acceptable_word
bool tess_acceptable_word(WERD_RES *word)
Definition: tessbox.cpp:61
tesseract
Definition: baseapi.h:65
tesseract::Wordrec::set_pass2
void set_pass2()
Definition: tface.cpp:127
WERD_RES::SetupFake
void SetupFake(const UNICHARSET &uch)
Definition: pageres.cpp:348
WERD_RES::word
WERD * word
Definition: pageres.h:180
tesseract::Tesseract::tess_segment_pass_n
void tess_segment_pass_n(int pass_n, WERD_RES *word)
Definition: tessbox.cpp:31