#include <char_set.h>
Definition at line 42 of file char_set.h.
◆ CharSet()
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_));
◆ ~CharSet()
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_;
◆ ClassCount()
int tesseract::CharSet::ClassCount |
( |
| ) |
const |
|
inline |
Definition at line 111 of file char_set.h.
111 {
return class_cnt_; }
◆ ClassID() [1/2]
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];
◆ ClassID() [2/2]
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];
◆ ClassString()
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());
◆ Create()
Definition at line 54 of file char_set.cpp.
59 bool cube_unicharset_exists;
60 if (!(cube_unicharset_exists =
63 fprintf(stderr,
"Cube ERROR (CharSet::Create): could not find " 64 "either cube or tesseract unicharset\n");
67 FILE *charset_fp = tessdata_manager->GetDataFilePtr();
69 fprintf(stderr,
"Cube ERROR (CharSet::Create): could not load " 78 if (cube_unicharset_exists) {
79 char_set->cube_unicharset_.load_from_file(charset_fp);
81 loaded = loaded && char_set->LoadSupportedCharList(
82 tessdata_manager->GetDataFilePtr(), tess_unicharset);
83 char_set->unicharset_ = &char_set->cube_unicharset_;
85 loaded = char_set->LoadSupportedCharList(charset_fp, NULL);
86 char_set->unicharset_ = tess_unicharset;
93 char_set->init_ =
true;
◆ InternalUnicharset()
UNICHARSET* tesseract::CharSet::InternalUnicharset |
( |
| ) |
|
|
inline |
Definition at line 121 of file char_set.h.
121 {
return unicharset_; }
◆ SharedUnicharset()
bool tesseract::CharSet::SharedUnicharset |
( |
| ) |
|
|
inline |
Definition at line 48 of file char_set.h.
48 {
return (unicharset_map_ == NULL); }
◆ UnicharID() [1/2]
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
◆ UnicharID() [2/2]
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: