#include <ratngs.h>
Public Member Functions | |
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) |
Public Member Functions inherited from ELIST_LINK | |
ELIST_LINK () | |
ELIST_LINK (const ELIST_LINK &) | |
void | operator= (const ELIST_LINK &) |
Static Public Member Functions | |
static const char * | permuter_name (uint8_t permuter) |
static tesseract::ScriptPos | ScriptPositionOf (bool print_debug, const UNICHARSET &unicharset, const TBOX &blob_box, UNICHAR_ID unichar_id) |
Static Public Attributes | |
static const float | kBadRating = 100000.0 |
Private Attributes | |
const UNICHARSET * | unicharset_ |
UNICHAR_ID * | unichar_ids_ |
tesseract::ScriptPos * | script_pos_ |
int * | state_ |
float * | certainties_ |
int | reserved_ |
int | length_ |
float | adjust_factor_ |
float | rating_ |
float | certainty_ |
float | min_x_height_ |
float | max_x_height_ |
uint8_t | permuter_ |
bool | unichars_in_script_order_ |
bool | dangerous_ambig_found_ |
STRING | unichar_string_ |
STRING | unichar_lengths_ |
|
inline |
|
inline |
|
inline |
WERD_CHOICE::WERD_CHOICE | ( | const char * | src_string, |
const UNICHARSET & | unicharset | ||
) |
Constructor to build a WERD_CHOICE from the given string. The function assumes that src_string is not nullptr.
|
inline |
WERD_CHOICE::~WERD_CHOICE | ( | ) |
|
inline |
void WERD_CHOICE::append_unichar_id | ( | UNICHAR_ID | unichar_id, |
int | blob_count, | ||
float | rating, | ||
float | certainty | ||
) |
append_unichar_id
Make sure there is enough space in the word for the new unichar id and call append_unichar_id_space_allocated().
|
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().
BLOB_CHOICE_LIST * WERD_CHOICE::blob_choices | ( | int | index, |
MATRIX * | ratings | ||
) | const |
|
inline |
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
void WERD_CHOICE::DisplaySegmentation | ( | TWERD * | word | ) |
|
inline |
Make more space in unichar_id_ and fragment_lengths_ arrays.
void WERD_CHOICE::GetNonSuperscriptSpan | ( | int * | start, |
int * | end | ||
) | const |
int WERD_CHOICE::GetTopScriptID | ( | ) | const |
bool WERD_CHOICE::has_rtl_unichar_id | ( | ) | const |
has_rtl_unichar_id
Returns true if unichar_ids contain at least one "strongly" RTL unichar.
|
inline |
Initializes WERD_CHOICE - reserves length slots in unichar_ids_ and fragment_length_ arrays. Sets other values to default (blank) values.
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.
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.
|
inline |
|
inline |
|
inline |
Set the fields in this choice to be default (bad) values.
MATRIX_COORD WERD_CHOICE::MatrixCoord | ( | int | index | ) | const |
|
inline |
|
inline |
WERD_CHOICE & WERD_CHOICE::operator+= | ( | const WERD_CHOICE & | second | ) |
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
WERD_CHOICE & WERD_CHOICE::operator= | ( | const WERD_CHOICE & | source | ) |
Allocate enough memory to hold a copy of source and copy over all the information from source to this WERD_CHOICE.
|
inline |
|
static |
const char * WERD_CHOICE::permuter_name | ( | ) | const |
|
inline |
void WERD_CHOICE::print | ( | const char * | msg | ) | const |
Print WERD_CHOICE to stdout.
void WERD_CHOICE::print_state | ( | const char * | msg | ) | const |
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.
|
inline |
|
inline |
|
inline |
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_.
void WERD_CHOICE::reverse_and_mirror_unichar_ids | ( | ) |
reverse_and_mirror_unichar_ids
Reverses and mirrors unichars in unichar_ids.
|
static |
|
inline |
void WERD_CHOICE::set_blob_choice | ( | int | index, |
int | blob_count, | ||
const BLOB_CHOICE * | blob_choice | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void WERD_CHOICE::SetAllScriptPositions | ( | tesseract::ScriptPos | position | ) |
void WERD_CHOICE::SetScriptPositions | ( | bool | small_caps, |
TWERD * | word, | ||
int | debug = 0 |
||
) |
void WERD_CHOICE::SetScriptPositions | ( | const tesseract::ScriptPos * | positions, |
int | length | ||
) |
WERD_CHOICE WERD_CHOICE::shallow_copy | ( | int | start, |
int | end | ||
) | const |
|
inline |
string_and_lengths
Populates the given word_str with unichars from unichar_ids and and word_lengths_str with the corresponding unichar lengths.
int WERD_CHOICE::TotalOfStates | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void WERD_CHOICE::UpdateStateForSplit | ( | int | blob_position | ) |
|
private |
|
private |
|
private |
|
private |
|
static |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
mutableprivate |
|
private |
|
private |