Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
hyphen.cpp
Go to the documentation of this file.
1
/* -*-C-*-
2
********************************************************************************
3
* File: hyphen.c (Formerly hyphen.c)
4
* Description: Functions for maintaining information about hyphenated words.
5
* Author: Mark Seaman, OCR Technology
6
* Created: Fri Oct 16 14:37:00 1987
7
* Modified: Thu Mar 14 11:09:43 1991 (Mark Seaman) marks@hpgrlt
8
* Language: C
9
* Package: N/A
10
* Status: Reusable Software Component
11
*
12
* (c) Copyright 1987, Hewlett-Packard Company.
13
** Licensed under the Apache License, Version 2.0 (the "License");
14
** you may not use this file except in compliance with the License.
15
** You may obtain a copy of the License at
16
** http://www.apache.org/licenses/LICENSE-2.0
17
** Unless required by applicable law or agreed to in writing, software
18
** distributed under the License is distributed on an "AS IS" BASIS,
19
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
** See the License for the specific language governing permissions and
21
** limitations under the License.
22
*
23
*********************************************************************************/
24
25
#include "
dict.h
"
26
27
namespace
tesseract
{
28
29
// Unless the previous word was the last one on the line, and the current
30
// one is not (thus it is the first one on the line), erase hyphen_word_,
31
// clear hyphen_active_dawgs_, hyphen_constraints_ update last_word_on_line_.
32
void
Dict::reset_hyphen_vars
(
bool
last_word_on_line) {
33
if
(!(last_word_on_line_ ==
true
&& last_word_on_line ==
false
)) {
34
if
(hyphen_word_ !=
NULL
) {
35
delete
hyphen_word_;
36
hyphen_word_ =
NULL
;
37
hyphen_active_dawgs_.
clear
();
38
hyphen_constraints_.
clear
();
39
}
40
}
41
if
(
hyphen_debug_level
) {
42
tprintf
(
"reset_hyphen_vars: last_word_on_line %d -> %d\n"
,
43
last_word_on_line_, last_word_on_line);
44
}
45
last_word_on_line_ = last_word_on_line;
46
}
47
48
// Update hyphen_word_, and copy the given DawgInfoVectors into
49
// hyphen_active_dawgs_ and hyphen_constraints_.
50
void
Dict::set_hyphen_word
(
const
WERD_CHOICE
&word,
51
const
DawgInfoVector
&active_dawgs,
52
const
DawgInfoVector
&constraints) {
53
if
(hyphen_word_ ==
NULL
) {
54
hyphen_word_ =
new
WERD_CHOICE
(word.
unicharset
());
55
hyphen_word_->
make_bad
();
56
}
57
if
(hyphen_word_->
rating
() > word.
rating
()) {
58
*hyphen_word_ = word;
59
// Remove the last unichar id as it is a hyphen, and remove
60
// any unichar_string/lengths that are present.
61
hyphen_word_->
remove_last_unichar_id
();
62
hyphen_active_dawgs_ = active_dawgs;
63
hyphen_constraints_ = constraints;
64
}
65
if
(
hyphen_debug_level
) {
66
hyphen_word_->
print
(
"set_hyphen_word: "
);
67
}
68
}
69
}
// namespace tesseract
mnt
data
src
tesseract-ocr
dict
hyphen.cpp
Generated on Thu Nov 1 2012 20:19:48 for Tesseract by
1.8.1