#include <trie.h>
|
| Trie (DawgType type, const STRING &lang, PermuterType perm, int unicharset_size, int debug_level) |
|
| ~Trie () override |
|
void | clear () |
|
EDGE_REF | edge_char_of (NODE_REF node_ref, UNICHAR_ID unichar_id, bool word_end) const override |
|
void | unichar_ids_of (NODE_REF node, NodeChildVector *vec, bool word_end) const override |
|
NODE_REF | next_node (EDGE_REF edge_ref) const override |
|
bool | end_of_word (EDGE_REF edge_ref) const override |
|
UNICHAR_ID | edge_letter (EDGE_REF edge_ref) const override |
|
void | KillEdge (EDGE_RECORD *edge_rec) const |
|
bool | DeadEdge (const EDGE_RECORD &edge_rec) const |
|
void | print_node (NODE_REF node, int max_num_edges) const override |
|
SquishedDawg * | trie_to_dawg () |
|
bool | read_and_add_word_list (const char *filename, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse) |
|
bool | read_word_list (const char *filename, GenericVector< STRING > *words) |
|
bool | add_word_list (const GenericVector< STRING > &words, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse_policy) |
|
bool | read_pattern_list (const char *filename, const UNICHARSET &unicharset) |
|
void | initialize_patterns (UNICHARSET *unicharset) |
|
void | unichar_id_to_patterns (UNICHAR_ID unichar_id, const UNICHARSET &unicharset, GenericVector< UNICHAR_ID > *vec) const override |
|
EDGE_REF | pattern_loop_edge (EDGE_REF edge_ref, UNICHAR_ID unichar_id, bool word_end) const override |
|
bool | add_word_to_dawg (const WERD_CHOICE &word, const GenericVector< bool > *repetitions) |
|
bool | add_word_to_dawg (const WERD_CHOICE &word) |
|
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 |
|
|
EDGE_RECORD * | deref_edge_ref (EDGE_REF edge_ref) const |
|
EDGE_REF | make_edge_ref (NODE_REF node_index, EDGE_INDEX edge_index) const |
|
void | link_edge (EDGE_RECORD *edge, NODE_REF nxt, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id) |
|
void | print_edge_rec (const EDGE_RECORD &edge_rec) const |
|
bool | can_be_eliminated (const EDGE_RECORD &edge_rec) |
|
void | print_all (const char *msg, int max_num_edges) |
|
bool | edge_char_of (NODE_REF node_ref, NODE_REF next_node, int direction, bool word_end, UNICHAR_ID unichar_id, EDGE_RECORD **edge_ptr, EDGE_INDEX *edge_index) const |
|
bool | add_edge_linkage (NODE_REF node1, NODE_REF node2, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id) |
|
bool | add_new_edge (NODE_REF node1, NODE_REF node2, bool repeats, bool word_end, UNICHAR_ID unichar_id) |
|
void | add_word_ending (EDGE_RECORD *edge, NODE_REF the_next_node, bool repeats, UNICHAR_ID unichar_id) |
|
NODE_REF | new_dawg_node () |
|
void | remove_edge_linkage (NODE_REF node1, NODE_REF node2, int direction, bool word_end, UNICHAR_ID unichar_id) |
|
void | remove_edge (NODE_REF node1, NODE_REF node2, bool word_end, UNICHAR_ID unichar_id) |
|
bool | eliminate_redundant_edges (NODE_REF node, const EDGE_RECORD &edge1, const EDGE_RECORD &edge2) |
|
bool | reduce_lettered_edges (EDGE_INDEX edge_index, UNICHAR_ID unichar_id, NODE_REF node, EDGE_VECTOR *backward_edges, NODE_MARKER reduced_nodes) |
|
void | sort_edges (EDGE_VECTOR *edges) |
|
void | reduce_node_input (NODE_REF node, NODE_MARKER reduced_nodes) |
|
UNICHAR_ID | character_class_to_pattern (char ch) |
|
| 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 |
|
Concrete class for Trie data structure that allows to store a list of words (extends Dawg base class) as well as dynamically add new words. This class stores a vector of pointers to TRIE_NODE_RECORDs, each of which has a vector of forward and backward edges.
Definition at line 56 of file trie.h.
◆ RTLReversePolicy
Enumerator |
---|
RRP_DO_NO_REVERSE | |
RRP_REVERSE_IF_HAS_RTL | |
RRP_FORCE_REVERSE | |
Definition at line 58 of file trie.h.
◆ Trie()
Definition at line 83 of file trie.h.
86 init(unicharset_size);
◆ ~Trie()
tesseract::Trie::~Trie |
( |
| ) |
|
|
inlineoverride |
◆ add_edge_linkage()
bool tesseract::Trie::add_edge_linkage |
( |
NODE_REF |
node1, |
|
|
NODE_REF |
node2, |
|
|
bool |
repeats, |
|
|
int |
direction, |
|
|
bool |
word_end, |
|
|
UNICHAR_ID |
unichar_id |
|
) |
| |
|
protected |
Definition at line 116 of file trie.cpp.
120 &(
nodes_[node1]->forward_edges) : &(
nodes_[node1]->backward_edges);
124 while (search_index < vec->size() &&
126 (*vec)[search_index]) == 1) {
130 search_index = vec->
size();
133 link_edge(&edge_rec, node2, marker_flag, direction, word_end, unichar_id);
137 (*vec)[edge_index] = edge_rec;
138 }
else if (search_index < vec->size()) {
139 vec->
insert(edge_rec, search_index);
◆ add_new_edge()
Definition at line 350 of file trie.h.
353 word_end, unichar_id) &&
355 word_end, unichar_id));
◆ add_word_ending()
Definition at line 152 of file trie.cpp.
159 unichar_id, &back_edge_ptr, &back_edge_index));
◆ add_word_list()
Definition at line 313 of file trie.cpp.
316 for (
int i = 0; i < words.
size(); ++i) {
318 if (word.length() == 0 || word.contains_unichar_id(INVALID_UNICHAR_ID))
321 word.has_rtl_unichar_id()) ||
323 word.reverse_and_mirror_unichar_ids();
328 tprintf(
"Error: word '%s' not in DAWG after adding it\n",
◆ add_word_to_dawg() [1/2]
bool tesseract::Trie::add_word_to_dawg |
( |
const WERD_CHOICE & |
word | ) |
|
|
inline |
◆ add_word_to_dawg() [2/2]
Definition at line 169 of file trie.cpp.
171 if (word.
length() <= 0)
return false;
174 for (
int i = 0; i < word.
length(); ++i) {
182 bool marker_flag =
false;
185 int32_t still_finding_chars =
true;
186 int32_t word_end =
false;
187 bool add_failed =
false;
193 for (i = 0; i < word.
length() - 1; ++i) {
195 marker_flag = (repetitions !=
nullptr) ? (*repetitions)[i] :
false;
197 if (still_finding_chars) {
199 unichar_id, &edge_ptr, &edge_index);
202 edge_index, last_node);
205 still_finding_chars =
false;
215 still_finding_chars =
false;
223 if (!still_finding_chars) {
227 if (the_next_node == 0) {
232 marker_flag, word_end, unichar_id)) {
237 last_node = the_next_node;
242 marker_flag = (repetitions !=
nullptr) ? (*repetitions)[i] :
false;
244 if (still_finding_chars &&
246 unichar_id, &edge_ptr, &edge_index)) {
250 marker_flag, unichar_id);
256 !
add_new_edge(last_node, the_next_node, marker_flag,
true, unichar_id))
260 tprintf(
"Re-initializing document dictionary...\n");
◆ can_be_eliminated()
bool tesseract::Trie::can_be_eliminated |
( |
const EDGE_RECORD & |
edge_rec | ) |
|
|
inlineprotected |
Definition at line 320 of file trie.h.
322 return (node_ref != NO_EDGE &&
323 nodes_[
static_cast<int>(node_ref)]->forward_edges.
size() == 1);
◆ character_class_to_pattern()
UNICHAR_ID tesseract::Trie::character_class_to_pattern |
( |
char |
ch | ) |
|
|
protected |
Definition at line 376 of file trie.cpp.
379 }
else if (ch ==
'd') {
381 }
else if (ch ==
'n') {
383 }
else if (ch ==
'p') {
385 }
else if (ch ==
'a') {
387 }
else if (ch ==
'A') {
390 return INVALID_UNICHAR_ID;
◆ clear()
void tesseract::Trie::clear |
( |
| ) |
|
◆ DeadEdge()
bool tesseract::Trie::DeadEdge |
( |
const EDGE_RECORD & |
edge_rec | ) |
const |
|
inline |
◆ deref_edge_ref()
Definition at line 285 of file trie.h.
286 int edge_index =
static_cast<int>(
288 int node_index =
static_cast<int>(
◆ edge_char_of() [1/2]
Definition at line 65 of file trie.cpp.
70 " direction %d word_end %d unichar_id %d, exploring node:\n",
71 node_ref,
next_node, direction, word_end, unichar_id);
72 if (node_ref != NO_EDGE) {
76 if (node_ref == NO_EDGE)
return false;
79 nodes_[node_ref]->forward_edges :
nodes_[node_ref]->backward_edges;
80 int vec_size = vec.
size();
86 while (start <= end) {
87 k = (start + end) >> 1;
91 *edge_ptr = &(vec[k]);
94 }
else if (compare == 1) {
101 for (
int i = 0; i < vec_size; ++i) {
107 *edge_ptr = &(edge_rec);
◆ edge_char_of() [2/2]
Returns the edge that corresponds to the letter out of this node.
Implements tesseract::Dawg.
Definition at line 98 of file trie.h.
103 &edge_ptr, &edge_index))
return NO_EDGE;
◆ edge_letter()
Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF.
Implements tesseract::Dawg.
Definition at line 142 of file trie.h.
143 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return INVALID_UNICHAR_ID;
◆ eliminate_redundant_edges()
Definition at line 558 of file trie.cpp.
562 tprintf(
"\nCollapsing node %" PRIi64
":\n", node);
586 curr_word_end, curr_unichar_id);
589 curr_word_end, curr_unichar_id,
590 &edge_ptr, &edge_index));
597 next_node2_num_edges, next_node2);
◆ end_of_word()
bool tesseract::Trie::end_of_word |
( |
EDGE_REF |
edge_ref | ) |
const |
|
inlineoverridevirtual |
Returns true if the edge indicated by the given EDGE_REF marks the end of a word.
Implements tesseract::Dawg.
Definition at line 136 of file trie.h.
137 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return false;
◆ get_reverse_policy_name()
const char * tesseract::Trie::get_reverse_policy_name |
( |
RTLReversePolicy |
reverse_policy | ) |
|
|
static |
◆ initialize_patterns()
void tesseract::Trie::initialize_patterns |
( |
UNICHARSET * |
unicharset | ) |
|
◆ KillEdge()
void tesseract::Trie::KillEdge |
( |
EDGE_RECORD * |
edge_rec | ) |
const |
|
inline |
◆ link_edge()
Sets up this edge record to the requested values.
Definition at line 300 of file trie.h.
◆ make_edge_ref()
Constructs EDGE_REF from the given node_index and edge_index.
Definition at line 294 of file trie.h.
◆ new_dawg_node()
NODE_REF tesseract::Trie::new_dawg_node |
( |
| ) |
|
|
protected |
◆ next_node()
Returns the next node visited by following the edge indicated by the given EDGE_REF.
Implements tesseract::Dawg.
Definition at line 127 of file trie.h.
128 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return NO_EDGE;
◆ pattern_loop_edge()
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 from tesseract::Dawg.
Definition at line 241 of file trie.h.
244 if (edge_ref == NO_EDGE)
return NO_EDGE;
◆ print_all()
void tesseract::Trie::print_all |
( |
const char * |
msg, |
|
|
int |
max_num_edges |
|
) |
| |
|
inlineprotected |
Definition at line 328 of file trie.h.
329 tprintf(
"\n__________________________\n%s\n", msg);
331 tprintf(
"__________________________\n");
◆ print_edge_rec()
void tesseract::Trie::print_edge_rec |
( |
const EDGE_RECORD & |
edge_rec | ) |
const |
|
inlineprotected |
Prints the given EDGE_RECORD.
Definition at line 311 of file trie.h.
◆ print_node()
void tesseract::Trie::print_node |
( |
NODE_REF |
node, |
|
|
int |
max_num_edges |
|
) |
| const |
|
overridevirtual |
Prints the contents of the node indicated by the given NODE_REF. At most max_num_edges will be printed.
Implements tesseract::Dawg.
Definition at line 697 of file trie.cpp.
698 if (node == NO_EDGE)
return;
703 for (
int dir = 0; dir < 2; ++dir) {
712 for (i = 0; (dir == 0 ? i < num_fwd : i < num_bkw) &&
713 i < max_num_edges; ++i) {
718 if (dir == 0 ? i < num_fwd : i < num_bkw)
tprintf(
"...");
◆ read_and_add_word_list()
Definition at line 281 of file trie.cpp.
286 word_list.
sort(sort_strings_by_dec_length);
◆ read_pattern_list()
bool tesseract::Trie::read_pattern_list |
( |
const char * |
filename, |
|
|
const UNICHARSET & |
unicharset |
|
) |
| |
Definition at line 394 of file trie.cpp.
397 tprintf(
"please call initialize_patterns() before read_pattern_list()\n");
401 FILE *pattern_file = fopen(filename,
"rb");
402 if (pattern_file ==
nullptr) {
403 tprintf(
"Error opening pattern file %s\n", filename);
407 int pattern_count = 0;
415 const char *str_ptr = string;
416 int step = unicharset.
step(str_ptr);
419 UNICHAR_ID curr_unichar_id = INVALID_UNICHAR_ID;
420 if (step == 1 && *str_ptr ==
'\\') {
422 if (*str_ptr ==
'\\') {
426 tprintf(
"Please provide at least %d concrete characters at the"
437 if (curr_unichar_id == INVALID_UNICHAR_ID) {
441 word.append_unichar_id(curr_unichar_id, 1, 0.0, 0.0);
444 step = unicharset.
step(str_ptr);
446 if (step == 1 && *str_ptr ==
'\\' && *(str_ptr+1) ==
'*') {
447 repetitions_vec[repetitions_vec.
size()-1] =
true;
449 step = unicharset.
step(str_ptr);
453 tprintf(
"Invalid user pattern %s\n",
string);
458 tprintf(
"Inserting expanded user pattern %s\n",
459 word.debug_string().string());
464 tprintf(
"Error: failed to insert pattern '%s'\n",
string);
470 tprintf(
"Read %d valid patterns from %s\n", pattern_count, filename);
472 fclose(pattern_file);
◆ read_word_list()
bool tesseract::Trie::read_word_list |
( |
const char * |
filename, |
|
|
GenericVector< STRING > * |
words |
|
) |
| |
Definition at line 290 of file trie.cpp.
296 word_file = fopen(filename,
"rb");
297 if (word_file ==
nullptr)
return false;
299 while (fgets(line_str,
sizeof(line_str), word_file) !=
nullptr) {
301 STRING word_str(line_str);
304 tprintf(
"Read %d words so far\n", word_count);
308 tprintf(
"Read %d words total.\n", word_count);
◆ reduce_lettered_edges()
Definition at line 605 of file trie.cpp.
613 bool did_something =
false;
614 for (
int i = edge_index; i < backward_edges->
size() - 1; ++i) {
616 UNICHAR_ID curr_unichar_id = INVALID_UNICHAR_ID;
617 while (i < backward_edges->size()) {
618 if (!
DeadEdge((*backward_edges)[i])) {
620 if (curr_unichar_id != unichar_id)
return did_something;
625 if (i == backward_edges->
size())
break;
626 const EDGE_RECORD &edge_rec = (*backward_edges)[i];
628 for (
int j = i + 1; j < backward_edges->
size(); ++j) {
629 const EDGE_RECORD &next_edge_rec = (*backward_edges)[j];
630 if (
DeadEdge(next_edge_rec))
continue;
632 if (next_id != unichar_id)
break;
638 did_something =
true;
643 return did_something;
◆ reduce_node_input()
Eliminates any redundant edges from this node in the Trie.
Definition at line 660 of file trie.cpp.
670 while (edge_index < backward_edges.
size()) {
671 if (
DeadEdge(backward_edges[edge_index]))
continue;
675 &backward_edges, reduced_nodes));
676 while (++edge_index < backward_edges.
size()) {
678 if (!
DeadEdge(backward_edges[edge_index]) &&
id != unichar_id)
break;
681 reduced_nodes[node] =
true;
688 for (
int i = 0; i < backward_edges.
size(); ++i) {
689 if (
DeadEdge(backward_edges[i]))
continue;
◆ remove_edge()
◆ remove_edge_linkage()
Definition at line 476 of file trie.cpp.
481 unichar_id, &edge_ptr, &edge_index));
489 }
else if (node1 == 0) {
◆ sort_edges()
void tesseract::Trie::sort_edges |
( |
EDGE_VECTOR * |
edges | ) |
|
|
protected |
Order num_edges of consecutive EDGE_RECORDS in the given EDGE_VECTOR in increasing order of unichar ids. This function is normally called for all edges in a single node, and since number of edges in each node is usually quite small, selection sort is used.
Definition at line 646 of file trie.cpp.
647 int num_edges = edges->
size();
648 if (num_edges <= 1)
return;
651 for (
int i = 0; i < num_edges; ++i) {
652 sort_vec.
push_back(KDPairInc<UNICHAR_ID, EDGE_RECORD>(
656 for (
int i = 0; i < num_edges; ++i)
657 (*edges)[i] = sort_vec[i].data;
◆ trie_to_dawg()
Definition at line 511 of file trie.cpp.
517 for (
int i = 0; i <
nodes_.
size(); i++) reduced_nodes[i] =
false;
519 delete[] reduced_nodes;
530 node_ref_map[i+1] = node_ref_map[i] +
nodes_[i]->forward_edges.
size();
532 int num_forward_edges = node_ref_map[i];
536 auto edge_array =
new EDGE_RECORD[num_forward_edges];
541 for (j = 0; j < end; ++j) {
552 delete[] node_ref_map;
554 return new SquishedDawg(edge_array, num_forward_edges,
type_,
lang_,
◆ unichar_id_to_patterns()
Fills vec with unichar ids that represent the character classes of the given unichar_id.
Reimplemented from tesseract::Dawg.
Definition at line 354 of file trie.cpp.
357 bool is_alpha = unicharset.
get_isalpha(unichar_id);
◆ unichar_ids_of()
Fills the given NodeChildVector with all the unichar ids (and the corresponding EDGE_REFs) for which there is an edge out of this node.
Implements tesseract::Dawg.
Definition at line 111 of file trie.h.
114 nodes_[
static_cast<int>(node)]->forward_edges;
115 for (
int i = 0; i < forward_edges.
size(); ++i) {
◆ alpha_pattern_
◆ alphanum_pattern_
◆ deref_direction_mask_
uint64_t tesseract::Trie::deref_direction_mask_ |
|
protected |
◆ deref_node_index_mask_
uint64_t tesseract::Trie::deref_node_index_mask_ |
|
protected |
◆ digit_pattern_
◆ initialized_patterns_
bool tesseract::Trie::initialized_patterns_ |
|
protected |
◆ kAlphanumPatternUnicode
const char tesseract::Trie::kAlphanumPatternUnicode = "\u2002" |
|
static |
◆ kAlphaPatternUnicode
const char tesseract::Trie::kAlphaPatternUnicode = "\u2000" |
|
static |
◆ kDigitPatternUnicode
const char tesseract::Trie::kDigitPatternUnicode = "\u2001" |
|
static |
◆ kLowerPatternUnicode
const char tesseract::Trie::kLowerPatternUnicode = "\u2004" |
|
static |
◆ kPuncPatternUnicode
const char tesseract::Trie::kPuncPatternUnicode = "\u2003" |
|
static |
◆ kSaneNumConcreteChars
const int tesseract::Trie::kSaneNumConcreteChars = 0 |
|
static |
◆ kUpperPatternUnicode
const char tesseract::Trie::kUpperPatternUnicode = "\u2005" |
|
static |
◆ lower_pattern_
◆ nodes_
◆ num_edges_
uint64_t tesseract::Trie::num_edges_ |
|
protected |
◆ punc_pattern_
◆ root_back_freelist_
◆ upper_pattern_
The documentation for this class was generated from the following files:
int given_greater_than_edge_rec(NODE_REF next_node, bool word_end, UNICHAR_ID unichar_id, const EDGE_RECORD &edge_rec) const
void chomp_string(char *str)
static const char kAlphanumPatternUnicode[]
EDGE_VECTOR forward_edges
NODE_REF next_node(EDGE_REF edge_ref) const override
static const int kSaneNumConcreteChars
void link_edge(EDGE_RECORD *edge, NODE_REF nxt, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id)
int step(const char *str) const
PermuterType perm_
Permuter code that should be used if the word is found in this Dawg.
void reduce_node_input(NODE_REF node, NODE_MARKER reduced_nodes)
bool initialized_patterns_
bool DeadEdge(const EDGE_RECORD &edge_rec) const
void init(int unicharset_size)
void print_edge_rec(const EDGE_RECORD &edge_rec) const
#define MAX_NODE_EDGES_DISPLAY
bool end_of_word_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns true if this edge marks the end of a word.
UNICHAR_ID unichar_id_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns UNICHAR_ID recorded in this edge.
UNICHAR_ID alpha_pattern_
bool get_isalpha(UNICHAR_ID unichar_id) const
bool eliminate_redundant_edges(NODE_REF node, const EDGE_RECORD &edge1, const EDGE_RECORD &edge2)
bool word_in_dawg(const WERD_CHOICE &word) const
Returns true if the given word is in the Dawg.
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
bool add_new_edge(NODE_REF node1, NODE_REF node2, bool repeats, bool word_end, UNICHAR_ID unichar_id)
uint64_t deref_node_index_mask_
NODE_REF next_node_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the next node visited by following this edge.
UNICHAR_ID lower_pattern_
bool get_isdigit(UNICHAR_ID unichar_id) const
EDGE_REF edge_char_of(NODE_REF node_ref, UNICHAR_ID unichar_id, bool word_end) const override
bool get_islower(UNICHAR_ID unichar_id) const
bool read_word_list(const char *filename, GenericVector< STRING > *words)
void KillEdge(EDGE_RECORD *edge_rec) const
EDGE_REF make_edge_ref(NODE_REF node_index, EDGE_INDEX edge_index) const
EDGE_RECORD * deref_edge_ref(EDGE_REF edge_ref) const
const STRING & lang() const
UNICHAR_ID unichar_id(int index) const
DLLSYM void tprintf(const char *format,...)
UNICHAR_ID upper_pattern_
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
void insert(const T &t, int index)
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.
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.
void print_all(const char *msg, int max_num_edges)
void print_node(NODE_REF node, int max_num_edges) const override
void add_word_ending(EDGE_RECORD *edge, NODE_REF the_next_node, bool repeats, UNICHAR_ID unichar_id)
void sort_edges(EDGE_VECTOR *edges)
void unichar_insert(const char *const unichar_repr, OldUncleanUnichars old_style)
GenericVector< EDGE_INDEX > root_back_freelist_
Dawg(DawgType type, const STRING &lang, PermuterType perm, int debug_level)
bool can_be_eliminated(const EDGE_RECORD &edge_rec)
bool add_word_list(const GenericVector< STRING > &words, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse_policy)
UNICHAR_ID alphanum_pattern_
static const char kAlphaPatternUnicode[]
EDGE_VECTOR backward_edges
int direction_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the direction flag of this edge.
static const char kPuncPatternUnicode[]
static const char kDigitPatternUnicode[]
const char *const RTLReversePolicyNames[]
void delete_data_pointers()
void remove_edge_linkage(NODE_REF node1, NODE_REF node2, int direction, bool word_end, UNICHAR_ID unichar_id)
bool add_word_to_dawg(const WERD_CHOICE &word, const GenericVector< bool > *repetitions)
bool add_edge_linkage(NODE_REF node1, NODE_REF node2, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id)
bool get_ispunctuation(UNICHAR_ID unichar_id) const
bool reduce_lettered_edges(EDGE_INDEX edge_index, UNICHAR_ID unichar_id, NODE_REF node, EDGE_VECTOR *backward_edges, NODE_MARKER reduced_nodes)
UNICHAR_ID digit_pattern_
UNICHAR_ID character_class_to_pattern(char ch)
bool get_isupper(UNICHAR_ID unichar_id) const
void remove_edge(NODE_REF node1, NODE_REF node2, bool word_end, UNICHAR_ID unichar_id)
static const char kLowerPatternUnicode[]
static const char kUpperPatternUnicode[]
bool marker_flag_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the marker flag of this edge.