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
char_altlist.h
Go to the documentation of this file.
1
/**********************************************************************
2
* File: char_altlist.h
3
* Description: Declaration of a Character Alternate List Class
4
* Author: Ahmad Abdulkader
5
* Created: 2007
6
*
7
* (C) Copyright 2008, Google Inc.
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
#ifndef CHAR_ALT_LIST_H
21
#define CHAR_ALT_LIST_H
22
23
// The CharAltList class holds the list of class alternates returned from
24
// a character classifier. Each alternate represents a class ID.
25
// It inherits from the AltList class.
26
// The CharAltList owns a CharSet object that maps a class-id to a string.
27
28
#include "
altlist.h
"
29
#include "
char_set.h
"
30
31
namespace
tesseract
{
32
class
CharAltList
:
public
AltList
{
33
public
:
34
CharAltList
(
const
CharSet
*char_set,
int
max_alt = kMaxCharAlt);
35
~CharAltList
();
36
37
// Sort the alternate list based on cost
38
void
Sort
();
39
// insert a new alternate with the specified class-id, cost and tag
40
bool
Insert
(
int
class_id,
int
cost,
void
*tag =
NULL
);
41
// returns the cost of a specific class ID
42
inline
int
ClassCost
(
int
class_id)
const
{
43
if
(class_id_cost_ ==
NULL
||
44
class_id < 0 ||
45
class_id >= char_set_->
ClassCount
()) {
46
return
WORST_COST
;
47
}
48
return
class_id_cost_[class_id];
49
}
50
// returns the alternate class-id corresponding to an alternate index
51
inline
int
Alt
(
int
alt_idx)
const
{
return
class_id_alt_[alt_idx]; }
52
// set the cost of a certain alternate
53
void
SetAltCost
(
int
alt_idx,
int
cost) {
54
alt_cost_
[alt_idx] = cost;
55
class_id_cost_[class_id_alt_[alt_idx]] = cost;
56
}
57
58
private
:
59
// character set object. Passed at construction time
60
const
CharSet
*char_set_;
61
// array of alternate class-ids
62
int
*class_id_alt_;
63
// array of alternate costs
64
int
*class_id_cost_;
65
// default max count of alternates
66
static
const
int
kMaxCharAlt = 256;
67
};
68
}
69
70
#endif // CHAR_ALT_LIST_H
mnt
data
src
tesseract-ocr
cube
char_altlist.h
Generated on Thu Nov 1 2012 20:19:47 for Tesseract by
1.8.1