Coverage Report

Created: 2025-06-13 07:15

/src/tesseract/src/ccmain/tessbox.cpp
Line
Count
Source (jump to first uncovered line)
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
23
/**
24
 * @name tess_segment_pass_n
25
 *
26
 * Segment a word using the pass_n conditions of the tess segmenter.
27
 * @param pass_n pass number
28
 * @param word word to do
29
 */
30
31
namespace tesseract {
32
113k
void Tesseract::tess_segment_pass_n(int pass_n, WERD_RES *word) {
33
113k
  int saved_enable_assoc = 0;
34
113k
  int saved_chop_enable = 0;
35
36
113k
  if (word->word->flag(W_DONT_CHOP)) {
37
3.12k
    saved_enable_assoc = wordrec_enable_assoc;
38
3.12k
    saved_chop_enable = chop_enable;
39
3.12k
    wordrec_enable_assoc.set_value(false);
40
3.12k
    chop_enable.set_value(false);
41
3.12k
  }
42
113k
  if (pass_n == 1) {
43
46.2k
    set_pass1();
44
66.8k
  } else {
45
66.8k
    set_pass2();
46
66.8k
  }
47
113k
  recog_word(word);
48
113k
  if (word->best_choice == nullptr) {
49
0
    word->SetupFake(*word->uch_set);
50
0
  }
51
113k
  if (word->word->flag(W_DONT_CHOP)) {
52
3.12k
    wordrec_enable_assoc.set_value(saved_enable_assoc);
53
3.12k
    chop_enable.set_value(saved_chop_enable);
54
3.12k
  }
55
113k
}
56
57
/**
58
 * @name tess_acceptable_word
59
 *
60
 * @return true if the word is regarded as "good enough".
61
 * @param word_choice after context
62
 * @param raw_choice before context
63
 */
64
113k
bool Tesseract::tess_acceptable_word(WERD_RES *word) {
65
113k
  return getDict().AcceptableResult(word);
66
113k
}
67
68
/**
69
 * @name tess_add_doc_word
70
 *
71
 * Add the given word to the document dictionary
72
 */
73
26.7k
void Tesseract::tess_add_doc_word(WERD_CHOICE *word_choice) {
74
26.7k
  getDict().add_document_word(*word_choice);
75
26.7k
}
76
} // namespace tesseract