tesseract
5.0.0-alpha-619-ge9db
|
#include <ratngs.h>
|
| WERD_CHOICE (const UNICHARSET *unicharset) |
|
| WERD_CHOICE (const UNICHARSET *unicharset, int reserved) |
|
| WERD_CHOICE (const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uint8_t src_permuter, const UNICHARSET &unicharset) |
|
| WERD_CHOICE (const char *src_string, const UNICHARSET &unicharset) |
|
| WERD_CHOICE (const WERD_CHOICE &word) |
|
| ~WERD_CHOICE () |
|
const UNICHARSET * | unicharset () const |
|
int | length () const |
|
float | adjust_factor () const |
|
void | set_adjust_factor (float factor) |
|
const UNICHAR_ID * | unichar_ids () const |
|
UNICHAR_ID | unichar_id (int index) const |
|
int | state (int index) const |
|
tesseract::ScriptPos | BlobPosition (int index) const |
|
float | rating () const |
|
float | certainty () const |
|
float | certainty (int index) const |
|
float | min_x_height () const |
|
float | max_x_height () const |
|
void | set_x_heights (float min_height, float max_height) |
|
uint8_t | permuter () const |
|
const char * | permuter_name () const |
|
BLOB_CHOICE_LIST * | blob_choices (int index, MATRIX *ratings) const |
|
MATRIX_COORD | MatrixCoord (int index) const |
|
void | set_unichar_id (UNICHAR_ID unichar_id, int index) |
|
bool | dangerous_ambig_found () const |
|
void | set_dangerous_ambig_found_ (bool value) |
|
void | set_rating (float new_val) |
|
void | set_certainty (float new_val) |
|
void | set_permuter (uint8_t perm) |
|
void | set_length (int len) |
|
void | double_the_size () |
| Make more space in unichar_id_ and fragment_lengths_ arrays. More...
|
|
void | init (int reserved) |
|
void | init (const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uint8_t src_permuter) |
|
void | make_bad () |
| Set the fields in this choice to be default (bad) values. More...
|
|
void | append_unichar_id_space_allocated (UNICHAR_ID unichar_id, int blob_count, float rating, float certainty) |
|
void | append_unichar_id (UNICHAR_ID unichar_id, int blob_count, float rating, float certainty) |
|
void | set_unichar_id (UNICHAR_ID unichar_id, int blob_count, float rating, float certainty, int index) |
|
void | set_blob_choice (int index, int blob_count, const BLOB_CHOICE *blob_choice) |
|
bool | contains_unichar_id (UNICHAR_ID unichar_id) const |
|
void | remove_unichar_ids (int index, int num) |
|
void | remove_last_unichar_id () |
|
void | remove_unichar_id (int index) |
|
bool | has_rtl_unichar_id () const |
|
void | reverse_and_mirror_unichar_ids () |
|
void | punct_stripped (int *start_core, int *end_core) const |
|
void | GetNonSuperscriptSpan (int *start, int *end) const |
|
WERD_CHOICE | shallow_copy (int start, int end) const |
|
void | string_and_lengths (STRING *word_str, STRING *word_lengths_str) const |
|
const STRING | debug_string () const |
|
bool | ContainsAnyNonSpaceDelimited () const |
|
bool | IsAllSpaces () const |
|
bool | set_unichars_in_script_order (bool in_script_order) |
|
bool | unichars_in_script_order () const |
|
const STRING & | unichar_string () const |
|
const STRING & | unichar_lengths () const |
|
void | SetScriptPositions (bool small_caps, TWERD *word, int debug=0) |
|
void | SetScriptPositions (const tesseract::ScriptPos *positions, int length) |
|
void | SetAllScriptPositions (tesseract::ScriptPos position) |
|
int | GetTopScriptID () const |
|
void | UpdateStateForSplit (int blob_position) |
|
int | TotalOfStates () const |
|
void | print () const |
|
void | print (const char *msg) const |
|
void | print_state (const char *msg) const |
|
void | DisplaySegmentation (TWERD *word) |
|
WERD_CHOICE & | operator+= (const WERD_CHOICE &second) |
|
WERD_CHOICE & | operator= (const WERD_CHOICE &source) |
|
| ELIST_LINK () |
|
| ELIST_LINK (const ELIST_LINK &) |
|
void | operator= (const ELIST_LINK &) |
|
Definition at line 261 of file ratngs.h.
◆ WERD_CHOICE() [1/5]
WERD_CHOICE::WERD_CHOICE |
( |
const UNICHARSET * |
unicharset | ) |
|
|
inline |
◆ WERD_CHOICE() [2/5]
WERD_CHOICE::WERD_CHOICE |
( |
const UNICHARSET * |
unicharset, |
|
|
int |
reserved |
|
) |
| |
|
inline |
◆ WERD_CHOICE() [3/5]
WERD_CHOICE::WERD_CHOICE |
( |
const char * |
src_string, |
|
|
const char * |
src_lengths, |
|
|
float |
src_rating, |
|
|
float |
src_certainty, |
|
|
uint8_t |
src_permuter, |
|
|
const UNICHARSET & |
unicharset |
|
) |
| |
|
inline |
Definition at line 270 of file ratngs.h.
272 const char *src_lengths,
275 uint8_t src_permuter,
278 this->
init(src_string, src_lengths, src_rating,
279 src_certainty, src_permuter);
◆ WERD_CHOICE() [4/5]
WERD_CHOICE::WERD_CHOICE |
( |
const char * |
src_string, |
|
|
const UNICHARSET & |
unicharset |
|
) |
| |
◆ WERD_CHOICE() [5/5]
◆ ~WERD_CHOICE()
WERD_CHOICE::~WERD_CHOICE |
( |
| ) |
|
◆ adjust_factor()
float WERD_CHOICE::adjust_factor |
( |
| ) |
const |
|
inline |
Definition at line 294 of file ratngs.h.
296 return adjust_factor_;
◆ append_unichar_id()
void WERD_CHOICE::append_unichar_id |
( |
UNICHAR_ID |
unichar_id, |
|
|
int |
blob_count, |
|
|
float |
rating, |
|
|
float |
certainty |
|
) |
| |
◆ append_unichar_id_space_allocated()
void WERD_CHOICE::append_unichar_id_space_allocated |
( |
UNICHAR_ID |
unichar_id, |
|
|
int |
blob_count, |
|
|
float |
rating, |
|
|
float |
certainty |
|
) |
| |
|
inline |
This function assumes that there is enough space reserved in the WERD_CHOICE for adding another unichar. This is an efficient alternative to append_unichar_id().
Definition at line 440 of file ratngs.h.
444 assert(reserved_ > length_);
◆ blob_choices()
BLOB_CHOICE_LIST * WERD_CHOICE::blob_choices |
( |
int |
index, |
|
|
MATRIX * |
ratings |
|
) |
| const |
Definition at line 292 of file ratngs.cpp.
295 BLOB_CHOICE_LIST* result = ratings->
get(coord.
col, coord.
row);
296 if (result ==
nullptr) {
297 result =
new BLOB_CHOICE_LIST;
298 ratings->
put(coord.
col, coord.
row, result);
◆ BlobPosition()
Definition at line 310 of file ratngs.h.
312 if (index < 0 || index >= length_)
314 return script_pos_[index];
◆ certainty() [1/2]
float WERD_CHOICE::certainty |
( |
| ) |
const |
|
inline |
◆ certainty() [2/2]
float WERD_CHOICE::certainty |
( |
int |
index | ) |
const |
|
inline |
Definition at line 321 of file ratngs.h.
323 return certainties_[index];
◆ contains_unichar_id()
bool WERD_CHOICE::contains_unichar_id |
( |
UNICHAR_ID |
unichar_id | ) |
const |
contains_unichar_id
Returns true if unichar_ids_ contain the given unichar_id, false otherwise.
Definition at line 328 of file ratngs.cpp.
330 for (
int i = 0; i < length_; ++i) {
◆ ContainsAnyNonSpaceDelimited()
bool WERD_CHOICE::ContainsAnyNonSpaceDelimited |
( |
| ) |
const |
|
inline |
Definition at line 502 of file ratngs.h.
504 for (
int i = 0; i < length_; ++i) {
◆ dangerous_ambig_found()
bool WERD_CHOICE::dangerous_ambig_found |
( |
| ) |
const |
|
inline |
Definition at line 351 of file ratngs.h.
353 return dangerous_ambig_found_;
◆ debug_string()
const STRING WERD_CHOICE::debug_string |
( |
| ) |
const |
|
inline |
Definition at line 493 of file ratngs.h.
496 for (
int i = 0; i < length_; ++i) {
◆ DisplaySegmentation()
void WERD_CHOICE::DisplaySegmentation |
( |
TWERD * |
word | ) |
|
Definition at line 763 of file ratngs.cpp.
765 #ifndef GRAPHICS_DISABLED
767 const int kNumColors = 6;
771 bool already_done = prev_drawn_state.
size() == length_;
772 if (!already_done) prev_drawn_state.
init_to_size(length_, 0);
773 for (
int i = 0; i < length_; ++i) {
774 if (prev_drawn_state[i] != state_[i]) {
775 already_done =
false;
777 prev_drawn_state[i] = state_[i];
779 if (already_done || word->
blobs.
empty())
return;
782 if (segm_window ==
nullptr) {
783 segm_window =
new ScrollView(
"Segmentation", 5, 10, 500, 256,
784 2000.0, 256.0,
true);
786 segm_window->
Clear();
791 for (
int c = 0; c < length_; ++c) {
793 static_cast<ScrollView::Color>(c % kNumColors + 3);
794 for (
int i = 0; i < state_[c]; ++i, ++blob_index) {
797 blob->
plot(segm_window, color, color);
◆ double_the_size()
void WERD_CHOICE::double_the_size |
( |
| ) |
|
|
inline |
Make more space in unichar_id_ and fragment_lengths_ arrays.
Definition at line 375 of file ratngs.h.
379 reserved_, unichar_ids_);
381 reserved_, script_pos_);
385 reserved_, certainties_);
391 certainties_ =
new float[1];
◆ GetNonSuperscriptSpan()
void WERD_CHOICE::GetNonSuperscriptSpan |
( |
int * |
start, |
|
|
int * |
end |
|
) |
| const |
Definition at line 399 of file ratngs.cpp.
408 while (start < end &&
◆ GetTopScriptID()
int WERD_CHOICE::GetTopScriptID |
( |
| ) |
const |
Definition at line 669 of file ratngs.cpp.
672 int *sid =
new int[max_script];
674 for (x = 0; x < max_script; x++) sid[x] = 0;
675 for (x = 0; x < length_; ++x) {
693 for (x = 1; x < max_script; x++)
694 if (sid[x] >= sid[max_sid]) max_sid = x;
695 if (sid[max_sid] < length_ / 2)
◆ has_rtl_unichar_id()
bool WERD_CHOICE::has_rtl_unichar_id |
( |
| ) |
const |
has_rtl_unichar_id
Returns true if unichar_ids contain at least one "strongly" RTL unichar.
Definition at line 433 of file ratngs.cpp.
436 for (i = 0; i < length_; ++i) {
◆ init() [1/2]
void WERD_CHOICE::init |
( |
const char * |
src_string, |
|
|
const char * |
src_lengths, |
|
|
float |
src_rating, |
|
|
float |
src_certainty, |
|
|
uint8_t |
src_permuter |
|
) |
| |
Helper function to build a WERD_CHOICE from the given string, fragment lengths, rating, certainty and permuter. The function assumes that src_string is not nullptr. src_lengths argument could be nullptr, in which case the unichars in src_string are assumed to all be of length 1.
WERD_CHOICE::init
Helper function to build a WERD_CHOICE from the given string, fragment lengths, rating, certainty and permuter.
The function assumes that src_string is not nullptr. src_lengths argument could be nullptr, in which case the unichars in src_string are assumed to all be of length 1.
Definition at line 247 of file ratngs.cpp.
253 int src_string_len = strlen(src_string);
254 if (src_string_len == 0) {
257 this->
init(src_lengths ? strlen(src_lengths): src_string_len);
260 for (
int i = 0; i < length_; ++i) {
261 int unichar_length = src_lengths ? src_lengths[i] : 1;
265 certainties_[i] = src_certainty;
266 offset += unichar_length;
269 adjust_factor_ = 1.0f;
270 rating_ = src_rating;
271 certainty_ = src_certainty;
272 permuter_ = src_permuter;
273 dangerous_ambig_found_ =
false;
◆ init() [2/2]
void WERD_CHOICE::init |
( |
int |
reserved | ) |
|
|
inline |
Initializes WERD_CHOICE - reserves length slots in unichar_ids_ and fragment_length_ arrays. Sets other values to default (blank) values.
Definition at line 397 of file ratngs.h.
399 reserved_ = reserved;
403 state_ =
new int[reserved];
404 certainties_ =
new float[reserved];
406 unichar_ids_ =
nullptr;
407 script_pos_ =
nullptr;
409 certainties_ =
nullptr;
412 adjust_factor_ = 1.0f;
414 certainty_ = FLT_MAX;
415 min_x_height_ = 0.0f;
416 max_x_height_ = FLT_MAX;
418 unichars_in_script_order_ =
false;
419 dangerous_ambig_found_ =
false;
◆ IsAllSpaces()
bool WERD_CHOICE::IsAllSpaces |
( |
| ) |
const |
|
inline |
Definition at line 509 of file ratngs.h.
511 for (
int i = 0; i < length_; ++i) {
◆ length()
int WERD_CHOICE::length |
( |
| ) |
const |
|
inline |
◆ make_bad()
void WERD_CHOICE::make_bad |
( |
| ) |
|
|
inline |
Set the fields in this choice to be default (bad) values.
Definition at line 431 of file ratngs.h.
435 certainty_ = -FLT_MAX;
◆ MatrixCoord()
Definition at line 304 of file ratngs.cpp.
307 for (
int i = 0; i < index; ++i)
309 int row = col + state_[index] - 1;
◆ max_x_height()
float WERD_CHOICE::max_x_height |
( |
| ) |
const |
|
inline |
Definition at line 327 of file ratngs.h.
329 return max_x_height_;
◆ min_x_height()
float WERD_CHOICE::min_x_height |
( |
| ) |
const |
|
inline |
Definition at line 324 of file ratngs.h.
326 return min_x_height_;
◆ operator+=()
WERD_CHOICE::operator+=
Cat a second word rating on the end of this current one. The ratings are added and the confidence is the min. If the permuters are NOT the same the permuter is set to COMPOUND_PERM
Definition at line 487 of file ratngs.cpp.
490 while (reserved_ < length_ + second.
length()) {
494 for (
int i = 0; i < second.
length(); ++i) {
495 unichar_ids_[length_ + i] = other_unichar_ids[i];
496 state_[length_ + i] = second.state_[i];
497 certainties_[length_ + i] = second.certainties_[i];
500 length_ += second.
length();
501 if (second.adjust_factor_ > adjust_factor_)
502 adjust_factor_ = second.adjust_factor_;
503 rating_ += second.
rating();
506 if (second.dangerous_ambig_found_)
507 dangerous_ambig_found_ =
true;
◆ operator=()
WERD_CHOICE::operator=
Allocate enough memory to hold a copy of source and copy over all the information from source to this WERD_CHOICE.
Definition at line 523 of file ratngs.cpp.
525 while (reserved_ < source.
length()) {
531 for (
int i = 0; i < source.
length(); ++i) {
532 unichar_ids_[i] = other_unichar_ids[i];
533 state_[i] = source.state_[i];
534 certainties_[i] = source.certainties_[i];
537 length_ = source.
length();
538 adjust_factor_ = source.adjust_factor_;
539 rating_ = source.
rating();
544 dangerous_ambig_found_ = source.dangerous_ambig_found_;
◆ permuter()
uint8_t WERD_CHOICE::permuter |
( |
| ) |
const |
|
inline |
◆ permuter_name() [1/2]
const char * WERD_CHOICE::permuter_name |
( |
| ) |
const |
Definition at line 285 of file ratngs.cpp.
287 return kPermuterTypeNames[permuter_];
◆ permuter_name() [2/2]
const char * WERD_CHOICE::permuter_name |
( |
uint8_t |
permuter | ) |
|
|
static |
◆ print() [1/2]
void WERD_CHOICE::print |
( |
| ) |
const |
|
inline |
◆ print() [2/2]
void WERD_CHOICE::print |
( |
const char * |
msg | ) |
const |
WERD_CHOICE::print
Print WERD_CHOICE to stdout.
Definition at line 726 of file ratngs.cpp.
729 for (
int i = 0; i < length_; ++i) {
732 tprintf(
" : R=%g, C=%g, F=%g, Perm=%d, xht=[%g,%g], ambig=%d\n",
733 rating_, certainty_, adjust_factor_, permuter_,
734 min_x_height_, max_x_height_, dangerous_ambig_found_);
736 for (
int i = 0; i < length_; ++i) {
740 for (
int i = 0; i < length_; ++i) {
744 for (
int i = 0; i < length_; ++i) {
748 for (
int i = 0; i < length_; ++i) {
749 tprintf(
"\t%.3f", certainties_[i]);
◆ print_state()
void WERD_CHOICE::print_state |
( |
const char * |
msg | ) |
const |
Definition at line 754 of file ratngs.cpp.
757 for (
int i = 0; i < length_; ++i)
◆ punct_stripped()
void WERD_CHOICE::punct_stripped |
( |
int * |
start, |
|
|
int * |
end |
|
) |
| const |
punct_stripped
Returns the half-open interval of unichar_id indices [start, end) which enclose the core portion of this word – the part after stripping punctuation from the left and right.
Definition at line 385 of file ratngs.cpp.
389 while (*start <
length() &&
◆ rating()
float WERD_CHOICE::rating |
( |
| ) |
const |
|
inline |
◆ remove_last_unichar_id()
void WERD_CHOICE::remove_last_unichar_id |
( |
| ) |
|
|
inline |
◆ remove_unichar_id()
void WERD_CHOICE::remove_unichar_id |
( |
int |
index | ) |
|
|
inline |
◆ remove_unichar_ids()
void WERD_CHOICE::remove_unichar_ids |
( |
int |
start, |
|
|
int |
num |
|
) |
| |
remove_unichar_ids
Removes num unichar ids starting from index start from unichar_ids_ and updates length_ and fragment_lengths_ to reflect this change. Note: this function does not modify rating_ and certainty_.
Definition at line 344 of file ratngs.cpp.
348 for (
int i = 0; i < num; ++i) {
350 state_[start - 1] += state_[start + i];
351 else if (start + num < length_)
352 state_[start + num] += state_[start + i];
354 for (
int i = start; i + num < length_; ++i) {
355 unichar_ids_[i] = unichar_ids_[i + num];
356 script_pos_[i] = script_pos_[i + num];
357 state_[i] = state_[i + num];
358 certainties_[i] = certainties_[i + num];
◆ reverse_and_mirror_unichar_ids()
void WERD_CHOICE::reverse_and_mirror_unichar_ids |
( |
| ) |
|
reverse_and_mirror_unichar_ids
Reverses and mirrors unichars in unichar_ids.
Definition at line 367 of file ratngs.cpp.
369 for (
int i = 0; i < length_ / 2; ++i) {
374 if (length_ % 2 != 0) {
◆ ScriptPositionOf()
ScriptPos WERD_CHOICE::ScriptPositionOf |
( |
bool |
print_debug, |
|
|
const UNICHARSET & |
unicharset, |
|
|
const TBOX & |
blob_box, |
|
|
UNICHAR_ID |
unichar_id |
|
) |
| |
|
static |
Definition at line 631 of file ratngs.cpp.
637 int top = blob_box.
top();
638 int bottom = blob_box.
bottom();
639 int min_bottom, max_bottom, min_top, max_top;
641 &min_bottom, &max_bottom,
649 }
else if (top < sub_thresh_top && bottom < sub_thresh_bot) {
651 }
else if (bottom > sup_thresh_bot) {
657 tprintf(
"%s Character %s[bot:%d top: %d] "
658 "bot_range[%d,%d] top_range[%d, %d] "
659 "sub_thresh[bot:%d top:%d] sup_thresh_bot %d\n",
662 min_bottom, max_bottom, min_top, max_top,
663 sub_thresh_bot, sub_thresh_top,
◆ set_adjust_factor()
void WERD_CHOICE::set_adjust_factor |
( |
float |
factor | ) |
|
|
inline |
Definition at line 297 of file ratngs.h.
299 adjust_factor_ = factor;
◆ set_blob_choice()
void WERD_CHOICE::set_blob_choice |
( |
int |
index, |
|
|
int |
blob_count, |
|
|
const BLOB_CHOICE * |
blob_choice |
|
) |
| |
Definition at line 314 of file ratngs.cpp.
317 unichar_ids_[index] = blob_choice->
unichar_id();
319 state_[index] = blob_count;
320 certainties_[index] = blob_choice->
certainty();
◆ set_certainty()
void WERD_CHOICE::set_certainty |
( |
float |
new_val | ) |
|
|
inline |
Definition at line 360 of file ratngs.h.
362 certainty_ = new_val;
◆ set_dangerous_ambig_found_()
void WERD_CHOICE::set_dangerous_ambig_found_ |
( |
bool |
value | ) |
|
|
inline |
Definition at line 354 of file ratngs.h.
356 dangerous_ambig_found_ = value;
◆ set_length()
void WERD_CHOICE::set_length |
( |
int |
len | ) |
|
|
inline |
◆ set_permuter()
void WERD_CHOICE::set_permuter |
( |
uint8_t |
perm | ) |
|
|
inline |
◆ set_rating()
void WERD_CHOICE::set_rating |
( |
float |
new_val | ) |
|
|
inline |
◆ set_unichar_id() [1/2]
void WERD_CHOICE::set_unichar_id |
( |
UNICHAR_ID |
unichar_id, |
|
|
int |
blob_count, |
|
|
float |
rating, |
|
|
float |
certainty, |
|
|
int |
index |
|
) |
| |
|
inline |
Definition at line 452 of file ratngs.h.
455 assert(index < length_);
457 state_[index] = blob_count;
◆ set_unichar_id() [2/2]
void WERD_CHOICE::set_unichar_id |
( |
UNICHAR_ID |
unichar_id, |
|
|
int |
index |
|
) |
| |
|
inline |
Definition at line 347 of file ratngs.h.
349 assert(index < length_);
◆ set_unichars_in_script_order()
bool WERD_CHOICE::set_unichars_in_script_order |
( |
bool |
in_script_order | ) |
|
|
inline |
Definition at line 519 of file ratngs.h.
521 return unichars_in_script_order_ = in_script_order;
◆ set_x_heights()
void WERD_CHOICE::set_x_heights |
( |
float |
min_height, |
|
|
float |
max_height |
|
) |
| |
|
inline |
Definition at line 330 of file ratngs.h.
332 min_x_height_ = min_height;
333 max_x_height_ = max_height;
◆ SetAllScriptPositions()
Definition at line 625 of file ratngs.cpp.
627 for (
int i = 0; i < length_; ++i)
628 script_pos_[i] = position;
◆ SetScriptPositions() [1/2]
void WERD_CHOICE::SetScriptPositions |
( |
bool |
small_caps, |
|
|
TWERD * |
word, |
|
|
int |
debug = 0 |
|
) |
| |
Definition at line 552 of file ratngs.cpp.
555 for (
int i = 0; i < length_; ++i)
561 int position_counts[4] = { 0, 0, 0, 0 };
564 for (
int blob_index = 0; blob_index < length_; ++blob_index, ++chunk_index) {
568 if (state_ !=
nullptr) {
569 for (
int i = 1; i < state_[blob_index]; ++i) {
571 tblob = word->
blobs[chunk_index];
580 position_counts[script_pos_[blob_index]]++;
587 tprintf(
"Most characters of %s are subscript or superscript.\n"
588 "That seems wrong, so I'll assume we got the baseline wrong\n",
591 for (
int i = 0; i < length_; i++) {
594 position_counts[sp]--;
605 for (
int blob_index = 0; blob_index < length_; ++blob_index) {
611 chunk_index += state_ !=
nullptr ? state_[blob_index] : 1;
◆ SetScriptPositions() [2/2]
Definition at line 615 of file ratngs.cpp.
619 if (positions != script_pos_) {
620 delete [] script_pos_;
622 memcpy(script_pos_, positions,
sizeof(positions[0]) *
length);
◆ shallow_copy()
WERD_CHOICE WERD_CHOICE::shallow_copy |
( |
int |
start, |
|
|
int |
end |
|
) |
| const |
Definition at line 416 of file ratngs.cpp.
420 if (end < start) { end = start; }
422 for (
int i = start; i < end; i++) {
423 retval.append_unichar_id_space_allocated(
424 unichar_ids_[i], state_[i], 0.0f, certainties_[i]);
◆ state()
int WERD_CHOICE::state |
( |
int |
index | ) |
const |
|
inline |
Definition at line 307 of file ratngs.h.
309 return state_[index];
◆ string_and_lengths()
void WERD_CHOICE::string_and_lengths |
( |
STRING * |
word_str, |
|
|
STRING * |
word_lengths_str |
|
) |
| const |
string_and_lengths
Populates the given word_str with unichars from unichar_ids and and word_lengths_str with the corresponding unichar lengths.
Definition at line 451 of file ratngs.cpp.
455 if (word_lengths_str !=
nullptr) *word_lengths_str =
"";
456 for (
int i = 0; i < length_; ++i) {
459 if (word_lengths_str !=
nullptr) {
460 *word_lengths_str += strlen(ch);
◆ TotalOfStates()
int WERD_CHOICE::TotalOfStates |
( |
| ) |
const |
Definition at line 713 of file ratngs.cpp.
715 int total_chunks = 0;
716 for (
int i = 0; i < length_; ++i) {
717 total_chunks += state_[i];
◆ unichar_id()
UNICHAR_ID WERD_CHOICE::unichar_id |
( |
int |
index | ) |
const |
|
inline |
Definition at line 303 of file ratngs.h.
305 assert(index < length_);
306 return unichar_ids_[index];
◆ unichar_ids()
const UNICHAR_ID* WERD_CHOICE::unichar_ids |
( |
| ) |
const |
|
inline |
◆ unichar_lengths()
const STRING& WERD_CHOICE::unichar_lengths |
( |
| ) |
const |
|
inline |
Definition at line 536 of file ratngs.h.
539 return unichar_lengths_;
◆ unichar_string()
const STRING& WERD_CHOICE::unichar_string |
( |
| ) |
const |
|
inline |
Definition at line 529 of file ratngs.h.
532 return unichar_string_;
◆ unichars_in_script_order()
bool WERD_CHOICE::unichars_in_script_order |
( |
| ) |
const |
|
inline |
Definition at line 523 of file ratngs.h.
525 return unichars_in_script_order_;
◆ unicharset()
const UNICHARSET* WERD_CHOICE::unicharset |
( |
| ) |
const |
|
inline |
◆ UpdateStateForSplit()
void WERD_CHOICE::UpdateStateForSplit |
( |
int |
blob_position | ) |
|
Definition at line 701 of file ratngs.cpp.
703 int total_chunks = 0;
704 for (
int i = 0; i < length_; ++i) {
705 total_chunks += state_[i];
706 if (total_chunks > blob_position) {
◆ kBadRating
const float WERD_CHOICE::kBadRating = 100000.0 |
|
static |
The documentation for this class was generated from the following files:
Direction get_direction(UNICHAR_ID unichar_id) const
const STRING & unichar_string() const
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
UNICHAR_ID unichar_id(int index) const
const char * id_to_unichar_ext(UNICHAR_ID id) const
bool get_isdigit(UNICHAR_ID unichar_id) const
int TotalOfStates() const
void plot(ScrollView *window, ScrollView::Color color, ScrollView::Color child_color)
void make_bad()
Set the fields in this choice to be default (bad) values.
static T * double_the_size_memcpy(int current_size, T *data)
const int kMinSuperscriptOffset
bool IsSpaceDelimited(UNICHAR_ID unichar_id) const
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
const UNICHARSET * unicharset() const
static const float kBadRating
tesseract::ScriptPos BlobPosition(int index) const
void ZoomToRectangle(int x1, int y1, int x2, int y2)
UNICHAR_ID unichar_id() const
int get_script(UNICHAR_ID unichar_id) const
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
void set_unichar_id(UNICHAR_ID unichar_id, int index)
float min_x_height() const
STRING debug_str(UNICHAR_ID id) const
const char * c_str() const
void get_top_bottom(UNICHAR_ID unichar_id, int *min_bottom, int *max_bottom, int *min_top, int *max_top) const
MATRIX_COORD MatrixCoord(int index) const
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
GenericVector< TBLOB * > blobs
UNICHAR_ID get_mirror(UNICHAR_ID unichar_id) const
static std::string CleanupString(const char *utf8_str)
const int kMaxDropCapBottom
TBOX bounding_box() const
int get_script_table_size() const
WERD_CHOICE & operator=(const WERD_CHOICE &source)
void init_to_size(int size, const T &t)
void put(ICOORD pos, const T &thing)
DLLSYM void tprintf(const char *format,...)
WERD_CHOICE(const UNICHARSET *unicharset)
static tesseract::ScriptPos ScriptPositionOf(bool print_debug, const UNICHARSET &unicharset, const TBOX &blob_box, UNICHAR_ID unichar_id)
void remove_unichar_ids(int index, int num)
const UNICHAR_ID * unichar_ids() const
void remove_unichar_id(int index)
const char * id_to_unichar(UNICHAR_ID id) const
char window_wait(ScrollView *win)
const int kBlnBaselineOffset
const char * ScriptPosToString(enum ScriptPos script_pos)
const int kMinSubscriptOffset
float max_x_height() const