Tesseract  3.02
tesseract-ocr/ccmain/tessbox.cpp
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        tessbox.cpp  (Formerly tessbox.c)
00003  * Description: Black boxed Tess for developing a resaljet.
00004  * Author:                                      Ray Smith
00005  * Created:                                     Thu Apr 23 11:03:36 BST 1992
00006  *
00007  * (C) Copyright 1992, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifdef _MSC_VER
00021 #pragma warning(disable:4244)  // Conversion warnings
00022 #endif
00023 
00024 #include "mfcpch.h"
00025 #include          "tfacep.h"
00026 #include          "tfacepp.h"
00027 #include          "tessbox.h"
00028 #include "mfoutline.h"
00029 #include "tesseractclass.h"
00030 
00031 #define EXTERN
00032 
00041 namespace tesseract {
00042 void Tesseract::tess_segment_pass1(WERD_RES *word,
00043                                    BLOB_CHOICE_LIST_CLIST *blob_choices) {
00044   int saved_enable_assoc = 0;
00045   int saved_chop_enable = 0;
00046 
00047   if (word->word->flag(W_DONT_CHOP)) {
00048     saved_enable_assoc = wordrec_enable_assoc;
00049     saved_chop_enable = chop_enable;
00050     wordrec_enable_assoc.set_value(0);
00051     chop_enable.set_value(0);
00052     if (word->word->flag(W_REP_CHAR))
00053       getDict().permute_only_top.set_value(true);
00054   }
00055   set_pass1();
00056   recog_word(word, blob_choices);
00057   if (word->word->flag(W_DONT_CHOP)) {
00058     wordrec_enable_assoc.set_value(saved_enable_assoc);
00059     chop_enable.set_value(saved_chop_enable);
00060     getDict().permute_only_top.set_value(false);
00061   }
00062 }
00063 
00064 
00073 void Tesseract::tess_segment_pass2(WERD_RES *word,
00074                                    BLOB_CHOICE_LIST_CLIST *blob_choices) {
00075   int saved_enable_assoc = 0;
00076   int saved_chop_enable = 0;
00077 
00078   if (word->word->flag(W_DONT_CHOP)) {
00079     saved_enable_assoc = wordrec_enable_assoc;
00080     saved_chop_enable = chop_enable;
00081     wordrec_enable_assoc.set_value(0);
00082     chop_enable.set_value(0);
00083     if (word->word->flag(W_REP_CHAR))
00084       getDict().permute_only_top.set_value(true);
00085   }
00086   set_pass2();
00087   recog_word(word, blob_choices);
00088   if (word->word->flag(W_DONT_CHOP)) {
00089     wordrec_enable_assoc.set_value(saved_enable_assoc);
00090     chop_enable.set_value(saved_chop_enable);
00091     getDict().permute_only_top.set_value(false);
00092   }
00093 }
00094 
00102 BOOL8 Tesseract::tess_acceptable_word(
00103     WERD_CHOICE *word_choice,  // after context
00104     WERD_CHOICE *raw_choice) {  // before context
00105   return getDict().AcceptableResult(*word_choice);
00106 }
00107 
00108 
00114 void Tesseract::tess_add_doc_word(WERD_CHOICE *word_choice) {
00115   getDict().add_document_word(*word_choice);
00116 }
00117 }  // namespace tesseract