#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 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 |
const UNICHAR_ID * | unichar_ids () const |
const UNICHAR_ID | unichar_id (int index) const |
const char * | fragment_lengths () const |
const char | fragment_length (int index) const |
float | rating () const |
float | certainty () const |
uinT8 | permuter () const |
const char * | permuter_name () const |
bool | fragment_mark () const |
BLOB_CHOICE_LIST_CLIST * | blob_choices () |
void | set_unichar_id (UNICHAR_ID unichar_id, int index) |
void | set_fragment_length (char flen, int index) |
void | set_rating (float new_val) |
void | set_certainty (float new_val) |
void | set_permuter (uinT8 perm) |
void | set_fragment_mark (bool new_fragment_mark) |
void | set_length (int len) |
void | set_blob_choices (BLOB_CHOICE_LIST_CLIST *blob_choices) |
void | double_the_size () |
Make more space in unichar_id_ and fragment_lengths_ arrays. | |
void | init (int reserved) |
void | init (const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uinT8 src_permuter) |
void | make_bad () |
Set the fields in this choice to be default (bad) values. | |
void | append_unichar_id_space_allocated (UNICHAR_ID unichar_id, char fragment_length, float rating, float certainty) |
void | append_unichar_id (UNICHAR_ID unichar_id, char fragment_length, float rating, float certainty) |
void | set_unichar_id (UNICHAR_ID unichar_id, char fragment_length, float rating, float certainty, int index) |
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 |
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 |
void | populate_unichars () |
void | depopulate_unichars () |
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 |
const void | print () const |
const void | print (const char *msg) const |
WERD_CHOICE & | operator+= (const WERD_CHOICE &second) |
WERD_CHOICE & | operator= (const WERD_CHOICE &source) |
Static Public Attributes | |
static const float | kBadRating |
WERD_CHOICE::WERD_CHOICE | ( | const UNICHARSET * | unicharset | ) | [inline] |
WERD_CHOICE::WERD_CHOICE | ( | const UNICHARSET * | unicharset, | |
int | reserved | |||
) | [inline] |
WERD_CHOICE::WERD_CHOICE | ( | const char * | src_string, | |
const char * | src_lengths, | |||
float | src_rating, | |||
float | src_certainty, | |||
uinT8 | src_permuter, | |||
const UNICHARSET & | unicharset | |||
) | [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 NULL.
WERD_CHOICE::WERD_CHOICE | ( | const WERD_CHOICE & | word | ) | [inline] |
WERD_CHOICE::~WERD_CHOICE | ( | ) |
void WERD_CHOICE::append_unichar_id | ( | UNICHAR_ID | unichar_id, | |
char | fragment_length, | |||
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().
void WERD_CHOICE::append_unichar_id_space_allocated | ( | UNICHAR_ID | unichar_id, | |
char | fragment_length, | |||
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().
BLOB_CHOICE_LIST_CLIST* WERD_CHOICE::blob_choices | ( | ) | [inline] |
float WERD_CHOICE::certainty | ( | ) | const [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.
const STRING WERD_CHOICE::debug_string | ( | ) | const [inline] |
void WERD_CHOICE::depopulate_unichars | ( | ) | [inline] |
Undoes populate_unichars, so that unichar_string_ and unichar_lengths_ are empty.
void WERD_CHOICE::double_the_size | ( | ) | [inline] |
Make more space in unichar_id_ and fragment_lengths_ arrays.
const char WERD_CHOICE::fragment_length | ( | int | index | ) | const [inline] |
const char* WERD_CHOICE::fragment_lengths | ( | ) | const [inline] |
bool WERD_CHOICE::fragment_mark | ( | ) | const [inline] |
bool WERD_CHOICE::has_rtl_unichar_id | ( | ) | const |
has_rtl_unichar_id
Returns true if unichar_ids contain at least one "strongly" RTL unichar.
void WERD_CHOICE::init | ( | const char * | src_string, | |
const char * | src_lengths, | |||
float | src_rating, | |||
float | src_certainty, | |||
uinT8 | 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 NULL. src_lengths argument could be NULL, 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 NULL. src_lengths argument could be NULL, in which case the unichars in src_string are assumed to all be of length 1.
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.
int WERD_CHOICE::length | ( | ) | const [inline] |
void WERD_CHOICE::make_bad | ( | ) | [inline] |
Set the fields in this choice to be default (bad) values.
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.
uinT8 WERD_CHOICE::permuter | ( | ) | const [inline] |
const char * WERD_CHOICE::permuter_name | ( | ) | const |
void WERD_CHOICE::populate_unichars | ( | ) | [inline] |
Since this function walks over the whole word to convert unichar ids to unichars, it is best to call it once, e.g. after all changes to unichar_ids_ in WERD_CHOICE are finished.
const void WERD_CHOICE::print | ( | const char * | msg | ) | const |
Print WERD_CHOICE to stdout.
const void WERD_CHOICE::print | ( | ) | const [inline] |
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.
float WERD_CHOICE::rating | ( | ) | const [inline] |
void WERD_CHOICE::remove_last_unichar_id | ( | ) | [inline] |
void WERD_CHOICE::remove_unichar_id | ( | int | index | ) | [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. Note: this function does not change unichar_string_, it only modifies unichar_ids array.
void WERD_CHOICE::set_blob_choices | ( | BLOB_CHOICE_LIST_CLIST * | blob_choices | ) |
Delete current blob_choices. Set the blob_choices to the given new list.
void WERD_CHOICE::set_certainty | ( | float | new_val | ) | [inline] |
void WERD_CHOICE::set_fragment_length | ( | char | flen, | |
int | index | |||
) | [inline] |
void WERD_CHOICE::set_fragment_mark | ( | bool | new_fragment_mark | ) | [inline] |
void WERD_CHOICE::set_length | ( | int | len | ) | [inline] |
void WERD_CHOICE::set_permuter | ( | uinT8 | perm | ) | [inline] |
void WERD_CHOICE::set_rating | ( | float | new_val | ) | [inline] |
void WERD_CHOICE::set_unichar_id | ( | UNICHAR_ID | unichar_id, | |
char | fragment_length, | |||
float | rating, | |||
float | certainty, | |||
int | index | |||
) | [inline] |
void WERD_CHOICE::set_unichar_id | ( | UNICHAR_ID | unichar_id, | |
int | index | |||
) | [inline] |
bool WERD_CHOICE::set_unichars_in_script_order | ( | bool | in_script_order | ) | [inline] |
WERD_CHOICE WERD_CHOICE::shallow_copy | ( | int | start, | |
int | end | |||
) | const |
string_and_lengths
Populates the given word_str with unichars from unichar_ids and and word_lengths_str with the corresponding unichar lengths.
const UNICHAR_ID WERD_CHOICE::unichar_id | ( | int | index | ) | const [inline] |
const UNICHAR_ID* WERD_CHOICE::unichar_ids | ( | ) | const [inline] |
const STRING& WERD_CHOICE::unichar_lengths | ( | ) | const [inline] |
This function should only be called if populate_unichars() was called and WERD_CHOICE did not change since then.
const STRING& WERD_CHOICE::unichar_string | ( | ) | const [inline] |
This function should only be called if populate_unichars() was called and WERD_CHOICE did not change since then.
bool WERD_CHOICE::unichars_in_script_order | ( | ) | const [inline] |
const UNICHARSET* WERD_CHOICE::unicharset | ( | ) | const [inline] |
const float WERD_CHOICE::kBadRating [static] |