#include <dawg.h>
Public Member Functions | |
DawgType | type () const |
const STRING & | lang () const |
PermuterType | permuter () const |
virtual | ~Dawg () |
bool | word_in_dawg (const WERD_CHOICE &word) const |
Returns true if the given word is in the Dawg. More... | |
bool | prefix_in_dawg (const WERD_CHOICE &prefix, bool requires_complete) const |
int | check_for_words (const char *filename, const UNICHARSET &unicharset, bool enable_wildcard) const |
void | iterate_words (const UNICHARSET &unicharset, TessCallback1< const WERD_CHOICE *> *cb) const |
void | iterate_words (const UNICHARSET &unicharset, TessCallback1< const char *> *cb) const |
virtual EDGE_REF | edge_char_of (NODE_REF node, UNICHAR_ID unichar_id, bool word_end) const =0 |
Returns the edge that corresponds to the letter out of this node. More... | |
virtual void | unichar_ids_of (NODE_REF node, NodeChildVector *vec, bool word_end) const =0 |
virtual NODE_REF | next_node (EDGE_REF edge_ref) const =0 |
virtual bool | end_of_word (EDGE_REF edge_ref) const =0 |
virtual UNICHAR_ID | edge_letter (EDGE_REF edge_ref) const =0 |
Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. More... | |
virtual void | print_node (NODE_REF node, int max_num_edges) const =0 |
virtual void | unichar_id_to_patterns (UNICHAR_ID unichar_id, const UNICHARSET &unicharset, GenericVector< UNICHAR_ID > *vec) const |
virtual EDGE_REF | pattern_loop_edge (EDGE_REF edge_ref, UNICHAR_ID unichar_id, bool word_end) const |
Static Public Attributes | |
static const int16_t | kDawgMagicNumber = 42 |
Magic number to determine endianness when reading the Dawg from file. More... | |
static const UNICHAR_ID | kPatternUnicharID = 0 |
Protected Member Functions | |
Dawg (DawgType type, const STRING &lang, PermuterType perm, int debug_level) | |
NODE_REF | next_node_from_edge_rec (const EDGE_RECORD &edge_rec) const |
Returns the next node visited by following this edge. More... | |
bool | marker_flag_from_edge_rec (const EDGE_RECORD &edge_rec) const |
Returns the marker flag of this edge. More... | |
int | direction_from_edge_rec (const EDGE_RECORD &edge_rec) const |
Returns the direction flag of this edge. More... | |
bool | end_of_word_from_edge_rec (const EDGE_RECORD &edge_rec) const |
Returns true if this edge marks the end of a word. More... | |
UNICHAR_ID | unichar_id_from_edge_rec (const EDGE_RECORD &edge_rec) const |
Returns UNICHAR_ID recorded in this edge. More... | |
void | set_next_node_in_edge_rec (EDGE_RECORD *edge_rec, EDGE_REF value) |
Sets the next node link for this edge in the Dawg. More... | |
void | set_marker_flag_in_edge_rec (EDGE_RECORD *edge_rec) |
Sets this edge record to be the last one in a sequence of edges. More... | |
int | given_greater_than_edge_rec (NODE_REF next_node, bool word_end, UNICHAR_ID unichar_id, const EDGE_RECORD &edge_rec) const |
bool | edge_rec_match (NODE_REF next_node, bool word_end, UNICHAR_ID unichar_id, NODE_REF other_next_node, bool other_word_end, UNICHAR_ID other_unichar_id) const |
void | init (int unicharset_size) |
bool | match_words (WERD_CHOICE *word, int32_t index, NODE_REF node, UNICHAR_ID wildcard) const |
void | iterate_words_rec (const WERD_CHOICE &word_so_far, NODE_REF to_explore, TessCallback1< const WERD_CHOICE *> *cb) const |
Protected Attributes | |
DawgType | type_ |
STRING | lang_ |
PermuterType | perm_ |
Permuter code that should be used if the word is found in this Dawg. More... | |
int | unicharset_size_ |
int | flag_start_bit_ |
int | next_node_start_bit_ |
uint64_t | next_node_mask_ |
uint64_t | flags_mask_ |
uint64_t | letter_mask_ |
int | debug_level_ |
Abstract class (an interface) that declares methods needed by the various tesseract classes to operate on SquishedDawg and Trie objects.
This class initializes all the edge masks (since their usage by SquishedDawg and Trie is identical) and implements simple accessors for each of the fields encoded in an EDGE_RECORD. This class also implements word_in_dawg() and check_for_words() (since they use only the public methods of SquishedDawg and Trie classes that are inherited from the Dawg base class).
|
virtualdefault |
|
inlineprotected |
int tesseract::Dawg::check_for_words | ( | const char * | filename, |
const UNICHARSET & | unicharset, | ||
bool | enable_wildcard | ||
) | const |
|
inlineprotected |
Returns the direction flag of this edge.
|
pure virtual |
Returns the edge that corresponds to the letter out of this node.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
|
pure virtual |
Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
|
inlineprotected |
Returns true if all the values are equal (any value matches next_node if next_node == NO_EDGE, any value matches word_end if word_end is false).
|
pure virtual |
Returns true if the edge indicated by the given EDGE_REF marks the end of a word.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
|
inlineprotected |
Returns true if this edge marks the end of a word.
|
inlineprotected |
Sequentially compares the given values of unichar ID, next node and word end marker with the values in the given EDGE_RECORD. Returns: 1 if at any step the given input value exceeds that of edge_rec (and all the values already checked are the same) 0 if edge_rec_match() returns true -1 otherwise
|
protected |
Sets unicharset_size_. Initializes the values of various masks from unicharset_size_.
void tesseract::Dawg::iterate_words | ( | const UNICHARSET & | unicharset, |
TessCallback1< const WERD_CHOICE *> * | cb | ||
) | const |
void tesseract::Dawg::iterate_words | ( | const UNICHARSET & | unicharset, |
TessCallback1< const char *> * | cb | ||
) | const |
|
protected |
|
inline |
|
inlineprotected |
Returns the marker flag of this edge.
|
protected |
Matches all of the words that are represented by this string. If wildcard is set to something other than INVALID_UNICHAR_ID, the *'s in this string are interpreted as wildcards. WERD_CHOICE param is not passed by const so that wildcard searches can modify it and work without having to copy WERD_CHOICEs.
|
pure virtual |
Returns the next node visited by following the edge indicated by the given EDGE_REF.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
|
inlineprotected |
Returns the next node visited by following this edge.
|
inlinevirtual |
Returns the given EDGE_REF if the EDGE_RECORD that it points to has a self loop and the given unichar_id matches the unichar_id stored in the EDGE_RECORD, returns NO_EDGE otherwise.
Reimplemented in tesseract::Trie.
|
inline |
bool tesseract::Dawg::prefix_in_dawg | ( | const WERD_CHOICE & | prefix, |
bool | requires_complete | ||
) | const |
|
pure virtual |
Prints the contents of the node indicated by the given NODE_REF. At most max_num_edges will be printed.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
|
inlineprotected |
Sets this edge record to be the last one in a sequence of edges.
|
inlineprotected |
Sets the next node link for this edge in the Dawg.
|
inline |
|
inlineprotected |
Returns UNICHAR_ID recorded in this edge.
|
inlinevirtual |
Fills vec with unichar ids that represent the character classes of the given unichar_id.
Reimplemented in tesseract::Trie.
|
pure virtual |
Fills the given NodeChildVector with all the unichar ids (and the corresponding EDGE_REFs) for which there is an edge out of this node.
Implemented in tesseract::SquishedDawg, and tesseract::Trie.
bool tesseract::Dawg::word_in_dawg | ( | const WERD_CHOICE & | word | ) | const |
Returns true if the given word is in the Dawg.
|
protected |
|
protected |
|
protected |
|
static |
Magic number to determine endianness when reading the Dawg from file.
|
static |
A special unichar id that indicates that any appropriate pattern (e.g.dicitonary word, 0-9 digit, etc) can be inserted instead Used for expressing patterns in punctuation and number Dawgs.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Permuter code that should be used if the word is found in this Dawg.
|
protected |
|
protected |