#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 263 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 272 of file ratngs.h.
279 this->
init(src_string, src_lengths, src_rating,
280 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 296 of file ratngs.h.
297 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 442 of file ratngs.h.
445 assert(reserved_ > length_);
◆ blob_choices()
BLOB_CHOICE_LIST * WERD_CHOICE::blob_choices |
( |
int |
index, |
|
|
MATRIX * |
ratings |
|
) |
| const |
Definition at line 294 of file ratngs.cpp.
296 BLOB_CHOICE_LIST* result = ratings->
get(coord.
col, coord.
row);
297 if (result ==
nullptr) {
298 result =
new BLOB_CHOICE_LIST;
299 ratings->
put(coord.
col, coord.
row, result);
◆ BlobPosition()
Definition at line 312 of file ratngs.h.
313 if (index < 0 || index >= length_)
315 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 323 of file ratngs.h.
324 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 330 of file ratngs.cpp.
331 for (
int i = 0; i < length_; ++i) {
◆ ContainsAnyNonSpaceDelimited()
bool WERD_CHOICE::ContainsAnyNonSpaceDelimited |
( |
| ) |
const |
|
inline |
Definition at line 504 of file ratngs.h.
505 for (
int i = 0; i < length_; ++i) {
◆ dangerous_ambig_found()
bool WERD_CHOICE::dangerous_ambig_found |
( |
| ) |
const |
|
inline |
Definition at line 353 of file ratngs.h.
354 return dangerous_ambig_found_;
◆ debug_string()
const STRING WERD_CHOICE::debug_string |
( |
| ) |
const |
|
inline |
Definition at line 495 of file ratngs.h.
497 for (
int i = 0; i < length_; ++i) {
498 word_str += unicharset_->
debug_str(unichar_ids_[i]);
◆ DisplaySegmentation()
void WERD_CHOICE::DisplaySegmentation |
( |
TWERD * |
word | ) |
|
Definition at line 765 of file ratngs.cpp.
766 #ifndef GRAPHICS_DISABLED
768 const int kNumColors = 6;
772 bool already_done = prev_drawn_state.
size() == length_;
773 if (!already_done) prev_drawn_state.
init_to_size(length_, 0);
774 for (
int i = 0; i < length_; ++i) {
775 if (prev_drawn_state[i] != state_[i]) {
776 already_done =
false;
778 prev_drawn_state[i] = state_[i];
780 if (already_done || word->
blobs.
empty())
return;
783 if (segm_window ==
nullptr) {
784 segm_window =
new ScrollView(
"Segmentation", 5, 10, 500, 256,
785 2000.0, 256.0,
true);
787 segm_window->
Clear();
792 for (
int c = 0; c < length_; ++c) {
795 for (
int i = 0; i < state_[c]; ++i, ++blob_index) {
798 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 377 of file ratngs.h.
380 reserved_, unichar_ids_);
382 reserved_, script_pos_);
386 reserved_, certainties_);
392 certainties_ =
new float[1];
◆ GetNonSuperscriptSpan()
void WERD_CHOICE::GetNonSuperscriptSpan |
( |
int * |
start, |
|
|
int * |
end |
|
) |
| const |
Definition at line 401 of file ratngs.cpp.
409 while (start < end &&
◆ GetTopScriptID()
int WERD_CHOICE::GetTopScriptID |
( |
| ) |
const |
Definition at line 671 of file ratngs.cpp.
673 int *sid =
new int[max_script];
675 for (x = 0; x < max_script; x++) sid[x] = 0;
676 for (x = 0; x < length_; ++x) {
694 for (x = 1; x < max_script; x++)
695 if (sid[x] >= sid[max_sid]) max_sid = x;
696 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 435 of file ratngs.cpp.
437 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 249 of file ratngs.cpp.
254 int src_string_len = strlen(src_string);
255 if (src_string_len == 0) {
258 this->
init(src_lengths ? strlen(src_lengths): src_string_len);
261 for (
int i = 0; i < length_; ++i) {
262 int unichar_length = src_lengths ? src_lengths[i] : 1;
264 unicharset_->
unichar_to_id(src_string+offset, unichar_length);
266 certainties_[i] = src_certainty;
267 offset += unichar_length;
270 adjust_factor_ = 1.0f;
271 rating_ = src_rating;
272 certainty_ = src_certainty;
273 permuter_ = src_permuter;
274 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 399 of file ratngs.h.
400 reserved_ = reserved;
404 state_ =
new int[reserved];
405 certainties_ =
new float[reserved];
407 unichar_ids_ =
nullptr;
408 script_pos_ =
nullptr;
410 certainties_ =
nullptr;
413 adjust_factor_ = 1.0f;
415 certainty_ = FLT_MAX;
416 min_x_height_ = 0.0f;
417 max_x_height_ = FLT_MAX;
419 unichars_in_script_order_ =
false;
420 dangerous_ambig_found_ =
false;
◆ IsAllSpaces()
bool WERD_CHOICE::IsAllSpaces |
( |
| ) |
const |
|
inline |
Definition at line 511 of file ratngs.h.
512 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 433 of file ratngs.h.
436 certainty_ = -FLT_MAX;
◆ MatrixCoord()
Definition at line 306 of file ratngs.cpp.
308 for (
int i = 0; i < index; ++i)
310 int row = col + state_[index] - 1;
◆ max_x_height()
float WERD_CHOICE::max_x_height |
( |
| ) |
const |
|
inline |
Definition at line 329 of file ratngs.h.
330 return max_x_height_;
◆ min_x_height()
float WERD_CHOICE::min_x_height |
( |
| ) |
const |
|
inline |
Definition at line 326 of file ratngs.h.
327 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 489 of file ratngs.cpp.
491 while (reserved_ < length_ + second.
length()) {
495 for (
int i = 0; i < second.
length(); ++i) {
496 unichar_ids_[length_ + i] = other_unichar_ids[i];
497 state_[length_ + i] = second.state_[i];
498 certainties_[length_ + i] = second.certainties_[i];
501 length_ += second.
length();
502 if (second.adjust_factor_ > adjust_factor_)
503 adjust_factor_ = second.adjust_factor_;
504 rating_ += second.
rating();
507 if (second.dangerous_ambig_found_)
508 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 525 of file ratngs.cpp.
526 while (reserved_ < source.
length()) {
530 unicharset_ = source.unicharset_;
532 for (
int i = 0; i < source.
length(); ++i) {
533 unichar_ids_[i] = other_unichar_ids[i];
534 state_[i] = source.state_[i];
535 certainties_[i] = source.certainties_[i];
538 length_ = source.
length();
539 adjust_factor_ = source.adjust_factor_;
540 rating_ = source.
rating();
545 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 287 of file ratngs.cpp.
288 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 728 of file ratngs.cpp.
730 for (
int i = 0; i < length_; ++i) {
733 tprintf(
" : R=%g, C=%g, F=%g, Perm=%d, xht=[%g,%g], ambig=%d\n",
734 rating_, certainty_, adjust_factor_, permuter_,
735 min_x_height_, max_x_height_, dangerous_ambig_found_);
737 for (
int i = 0; i < length_; ++i) {
741 for (
int i = 0; i < length_; ++i) {
745 for (
int i = 0; i < length_; ++i) {
749 for (
int i = 0; i < length_; ++i) {
750 tprintf(
"\t%.3f", certainties_[i]);
◆ print_state()
void WERD_CHOICE::print_state |
( |
const char * |
msg | ) |
const |
Definition at line 756 of file ratngs.cpp.
758 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 387 of file ratngs.cpp.
390 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 346 of file ratngs.cpp.
349 for (
int i = 0; i < num; ++i) {
351 state_[start - 1] += state_[start + i];
352 else if (start + num < length_)
353 state_[start + num] += state_[start + i];
355 for (
int i = start; i + num < length_; ++i) {
356 unichar_ids_[i] = unichar_ids_[i + num];
357 script_pos_[i] = script_pos_[i + num];
358 state_[i] = state_[i + num];
359 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 369 of file ratngs.cpp.
370 for (
int i = 0; i < length_ / 2; ++i) {
372 unichar_ids_[i] = unicharset_->
get_mirror(unichar_ids_[length_-1-i]);
373 unichar_ids_[length_-1-i] = unicharset_->
get_mirror(tmp_id);
375 if (length_ % 2 != 0) {
376 unichar_ids_[length_/2] = unicharset_->
get_mirror(unichar_ids_[length_/2]);
◆ ScriptPositionOf()
ScriptPos WERD_CHOICE::ScriptPositionOf |
( |
bool |
print_debug, |
|
|
const UNICHARSET & |
unicharset, |
|
|
const TBOX & |
blob_box, |
|
|
UNICHAR_ID |
unichar_id |
|
) |
| |
|
static |
Definition at line 633 of file ratngs.cpp.
638 int top = blob_box.
top();
639 int bottom = blob_box.
bottom();
640 int min_bottom, max_bottom, min_top, max_top;
642 &min_bottom, &max_bottom,
650 }
else if (top < sub_thresh_top && bottom < sub_thresh_bot) {
652 }
else if (bottom > sup_thresh_bot) {
658 tprintf(
"%s Character %s[bot:%d top: %d] "
659 "bot_range[%d,%d] top_range[%d, %d] "
660 "sub_thresh[bot:%d top:%d] sup_thresh_bot %d\n",
663 min_bottom, max_bottom, min_top, max_top,
664 sub_thresh_bot, sub_thresh_top,
◆ set_adjust_factor()
void WERD_CHOICE::set_adjust_factor |
( |
float |
factor | ) |
|
|
inline |
Definition at line 299 of file ratngs.h.
300 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 316 of file ratngs.cpp.
318 unichar_ids_[index] = blob_choice->
unichar_id();
320 state_[index] = blob_count;
321 certainties_[index] = blob_choice->
certainty();
◆ set_certainty()
void WERD_CHOICE::set_certainty |
( |
float |
new_val | ) |
|
|
inline |
Definition at line 362 of file ratngs.h.
363 certainty_ = new_val;
◆ set_dangerous_ambig_found_()
void WERD_CHOICE::set_dangerous_ambig_found_ |
( |
bool |
value | ) |
|
|
inline |
Definition at line 356 of file ratngs.h.
357 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 454 of file ratngs.h.
456 assert(index < length_);
458 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 349 of file ratngs.h.
350 assert(index < length_);
◆ set_unichars_in_script_order()
bool WERD_CHOICE::set_unichars_in_script_order |
( |
bool |
in_script_order | ) |
|
|
inline |
Definition at line 521 of file ratngs.h.
522 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 332 of file ratngs.h.
333 min_x_height_ = min_height;
334 max_x_height_ = max_height;
◆ SetAllScriptPositions()
Definition at line 627 of file ratngs.cpp.
628 for (
int i = 0; i < length_; ++i)
629 script_pos_[i] = position;
◆ SetScriptPositions() [1/2]
void WERD_CHOICE::SetScriptPositions |
( |
bool |
small_caps, |
|
|
TWERD * |
word, |
|
|
int |
debug = 0 |
|
) |
| |
Definition at line 554 of file ratngs.cpp.
556 for (
int i = 0; i < length_; ++i)
562 int position_counts[4] = { 0, 0, 0, 0 };
565 for (
int blob_index = 0; blob_index < length_; ++blob_index, ++chunk_index) {
569 if (state_ !=
nullptr) {
570 for (
int i = 1; i < state_[blob_index]; ++i) {
572 tblob = word->
blobs[chunk_index];
581 position_counts[script_pos_[blob_index]]++;
588 tprintf(
"Most characters of %s are subscript or superscript.\n"
589 "That seems wrong, so I'll assume we got the baseline wrong\n",
592 for (
int i = 0; i < length_; i++) {
595 position_counts[sp]--;
606 for (
int blob_index = 0; blob_index < length_; ++blob_index) {
612 chunk_index += state_ !=
nullptr ? state_[blob_index] : 1;
◆ SetScriptPositions() [2/2]
Definition at line 617 of file ratngs.cpp.
620 if (positions != script_pos_) {
621 delete [] script_pos_;
623 memcpy(script_pos_, positions,
sizeof(positions[0]) *
length);
◆ shallow_copy()
WERD_CHOICE WERD_CHOICE::shallow_copy |
( |
int |
start, |
|
|
int |
end |
|
) |
| const |
Definition at line 418 of file ratngs.cpp.
421 if (end < start) { end = start; }
423 for (
int i = start; i < end; i++) {
424 retval.append_unichar_id_space_allocated(
425 unichar_ids_[i], state_[i], 0.0f, certainties_[i]);
◆ state()
int WERD_CHOICE::state |
( |
int |
index | ) |
const |
|
inline |
Definition at line 309 of file ratngs.h.
310 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 453 of file ratngs.cpp.
456 if (word_lengths_str !=
nullptr) *word_lengths_str =
"";
457 for (
int i = 0; i < length_; ++i) {
460 if (word_lengths_str !=
nullptr) {
461 *word_lengths_str += strlen(ch);
◆ TotalOfStates()
int WERD_CHOICE::TotalOfStates |
( |
| ) |
const |
Definition at line 715 of file ratngs.cpp.
716 int total_chunks = 0;
717 for (
int i = 0; i < length_; ++i) {
718 total_chunks += state_[i];
◆ unichar_id()
UNICHAR_ID WERD_CHOICE::unichar_id |
( |
int |
index | ) |
const |
|
inline |
Definition at line 305 of file ratngs.h.
306 assert(index < length_);
307 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 538 of file ratngs.h.
540 return unichar_lengths_;
◆ unichar_string()
const STRING& WERD_CHOICE::unichar_string |
( |
| ) |
const |
|
inline |
Definition at line 531 of file ratngs.h.
533 return unichar_string_;
◆ unichars_in_script_order()
bool WERD_CHOICE::unichars_in_script_order |
( |
| ) |
const |
|
inline |
Definition at line 525 of file ratngs.h.
526 return unichars_in_script_order_;
◆ unicharset()
const UNICHARSET* WERD_CHOICE::unicharset |
( |
| ) |
const |
|
inline |
◆ UpdateStateForSplit()
void WERD_CHOICE::UpdateStateForSplit |
( |
int |
blob_position | ) |
|
Definition at line 703 of file ratngs.cpp.
704 int total_chunks = 0;
705 for (
int i = 0; i < length_; ++i) {
706 total_chunks += state_[i];
707 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:
void init_to_size(int size, const T &t)
int get_script_table_size() const
void set_unichar_id(UNICHAR_ID unichar_id, int index)
static std::string CleanupString(const char *utf8_str)
const char * string() const
tesseract::ScriptPos BlobPosition(int index) const
UNICHAR_ID unichar_id() const
const int kMaxDropCapBottom
const STRING & unichar_string() const
MATRIX_COORD MatrixCoord(int index) const
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
bool IsSpaceDelimited(UNICHAR_ID unichar_id) const
const char * id_to_unichar(UNICHAR_ID id) const
void remove_unichar_ids(int index, int num)
GenericVector< TBLOB * > blobs
const int kMinSuperscriptOffset
char window_wait(ScrollView *win)
bool get_isdigit(UNICHAR_ID unichar_id) const
STRING debug_str(UNICHAR_ID id) const
void get_top_bottom(UNICHAR_ID unichar_id, int *min_bottom, int *max_bottom, int *min_top, int *max_top) const
UNICHAR_ID unichar_id(int index) const
DLLSYM void tprintf(const char *format,...)
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
WERD_CHOICE & operator=(const WERD_CHOICE &source)
void ZoomToRectangle(int x1, int y1, int x2, int y2)
static tesseract::ScriptPos ScriptPositionOf(bool print_debug, const UNICHARSET &unicharset, const TBOX &blob_box, UNICHAR_ID unichar_id)
int get_script(UNICHAR_ID unichar_id) const
void put(ICOORD pos, const T &thing)
const UNICHAR_ID * unichar_ids() const
float max_x_height() const
const int kBlnBaselineOffset
float min_x_height() const
const UNICHARSET * unicharset() const
void make_bad()
Set the fields in this choice to be default (bad) values.
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
TBOX bounding_box() const
static const float kBadRating
static T * double_the_size_memcpy(int current_size, T *data)
const int kMinSubscriptOffset
Direction get_direction(UNICHAR_ID unichar_id) const
const char * id_to_unichar_ext(UNICHAR_ID id) const
int TotalOfStates() const
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
UNICHAR_ID get_mirror(UNICHAR_ID unichar_id) const
void plot(ScrollView *window, ScrollView::Color color, ScrollView::Color child_color)
const char * ScriptPosToString(enum ScriptPos script_pos)