#include <char_set.h>
Definition at line 42 of file char_set.h.
tesseract::CharSet::CharSet |
( |
| ) |
|
Definition at line 28 of file char_set.cpp.
30 class_strings_ =
NULL;
31 unicharset_map_ =
NULL;
35 memset(hash_bin_size_, 0,
sizeof(hash_bin_size_));
tesseract::CharSet::~CharSet |
( |
| ) |
|
Definition at line 38 of file char_set.cpp.
39 if (class_strings_ !=
NULL) {
40 for (
int cls = 0; cls < class_cnt_; cls++) {
41 if (class_strings_[cls] !=
NULL) {
42 delete class_strings_[cls];
45 delete []class_strings_;
46 class_strings_ =
NULL;
48 delete []unicharset_map_;
int tesseract::CharSet::ClassCount |
( |
| ) |
const |
|
inline |
Definition at line 111 of file char_set.h.
111 {
return class_cnt_; }
int tesseract::CharSet::ClassID |
( |
const char_32 * |
str | ) |
const |
|
inline |
Definition at line 54 of file char_set.h.
55 int hash_val = Hash(str);
56 if (hash_bin_size_[hash_val] == 0)
58 for (
int bin = 0; bin < hash_bin_size_[hash_val]; bin++) {
59 if (class_strings_[hash_bins_[hash_val][bin]]->compare(str) == 0)
60 return hash_bins_[hash_val][bin];
int tesseract::CharSet::ClassID |
( |
char_32 |
ch | ) |
const |
|
inline |
Definition at line 65 of file char_set.h.
66 int hash_val = Hash(ch);
67 if (hash_bin_size_[hash_val] == 0)
69 for (
int bin = 0; bin < hash_bin_size_[hash_val]; bin++) {
70 if ((*class_strings_[hash_bins_[hash_val][bin]])[0] == ch &&
71 class_strings_[hash_bins_[hash_val][bin]]->length() == 1) {
72 return hash_bins_[hash_val][bin];
const char_32* tesseract::CharSet::ClassString |
( |
int |
class_id | ) |
const |
|
inline |
Definition at line 104 of file char_set.h.
105 if (class_id < 0 || class_id >= class_cnt_) {
108 return reinterpret_cast<const char_32 *
>(class_strings_[class_id]->c_str());
Definition at line 54 of file char_set.cpp.
57 if (char_set ==
NULL) {
62 bool cube_unicharset_exists;
63 if (!(cube_unicharset_exists =
66 fprintf(stderr,
"Cube ERROR (CharSet::Create): could not find "
67 "either cube or tesseract unicharset\n");
70 FILE *charset_fp = tessdata_manager->GetDataFilePtr();
72 fprintf(stderr,
"Cube ERROR (CharSet::Create): could not load "
81 if (cube_unicharset_exists) {
82 char_set->cube_unicharset_.load_from_file(charset_fp);
84 loaded = loaded && char_set->LoadSupportedCharList(
85 tessdata_manager->GetDataFilePtr(), tess_unicharset);
86 char_set->unicharset_ = &char_set->cube_unicharset_;
88 loaded = char_set->LoadSupportedCharList(charset_fp,
NULL);
89 char_set->unicharset_ = tess_unicharset;
96 char_set->init_ =
true;
UNICHARSET* tesseract::CharSet::InternalUnicharset |
( |
| ) |
|
|
inline |
Definition at line 121 of file char_set.h.
121 {
return unicharset_; }
bool tesseract::CharSet::SharedUnicharset |
( |
| ) |
|
|
inline |
Definition at line 48 of file char_set.h.
48 {
return (unicharset_map_ ==
NULL); }
int tesseract::CharSet::UnicharID |
( |
const char_32 * |
str | ) |
const |
|
inline |
Definition at line 80 of file char_set.h.
82 if (class_id == INVALID_UNICHAR_ID)
83 return INVALID_UNICHAR_ID;
86 unichar_id = unicharset_map_[class_id];
88 unichar_id = class_id;
int ClassID(const char_32 *str) const
int tesseract::CharSet::UnicharID |
( |
char_32 |
ch | ) |
const |
|
inline |
Definition at line 92 of file char_set.h.
94 if (class_id == INVALID_UNICHAR_ID)
95 return INVALID_UNICHAR_ID;
98 unichar_id = unicharset_map_[class_id];
100 unichar_id = class_id;
int ClassID(const char_32 *str) const
The documentation for this class was generated from the following files: