90 int unicharset_size,
int debug_level) {
104 bool word_end)
const {
108 &edge_ptr, &edge_index))
return NO_EDGE;
117 bool word_end)
const {
119 nodes_[
static_cast<int>(node)]->forward_edges;
120 for (
int i = 0; i < forward_edges.
size(); ++i) {
133 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return NO_EDGE;
142 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return false;
148 if (edge_ref == NO_EDGE ||
num_edges_ == 0)
return INVALID_UNICHAR_ID;
250 bool word_end)
const {
251 if (edge_ref == NO_EDGE)
return NO_EDGE;
293 int edge_index =
static_cast<int>(
295 int node_index =
static_cast<int>(
329 return (node_ref != NO_EDGE &&
330 nodes_[static_cast<int>(node_ref)]->forward_edges.
size() == 1);
336 tprintf(
"\n__________________________\n%s\n", msg);
338 tprintf(
"__________________________\n");
358 bool repeats,
bool word_end,
UNICHAR_ID unichar_id) {
360 word_end, unichar_id) &&
362 word_end, unichar_id));
static const char kAlphanumPatternUnicode[]
Trie(DawgType type, const STRING &lang, PermuterType perm, int unicharset_size, int debug_level)
void add_word_ending(EDGE_RECORD *edge, NODE_REF the_next_node, bool repeats, UNICHAR_ID unichar_id)
bool marker_flag_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the marker flag of this edge.
void print_node(NODE_REF node, int max_num_edges) const
bool read_pattern_list(const char *filename, const UNICHARSET &unicharset)
uinT64 deref_direction_mask_
bool read_word_list(const char *filename, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse_policy, GenericVector< STRING > *words)
GenericVector< TRIE_NODE_RECORD * > TRIE_NODES
void initialize_patterns(UNICHARSET *unicharset)
static const int kSaneNumConcreteChars
static const char kUpperPatternUnicode[]
UNICHAR_ID alpha_pattern_
bool read_and_add_word_list(const char *filename, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse)
void KillEdge(EDGE_RECORD *edge_rec) const
NODE_REF next_node(EDGE_REF edge_ref) const
void print_all(const char *msg, int max_num_edges)
bool add_word_to_dawg(const WERD_CHOICE &word, const GenericVector< bool > *repetitions)
UNICHAR_ID character_class_to_pattern(char ch)
UNICHAR_ID upper_pattern_
void unichar_id_to_patterns(UNICHAR_ID unichar_id, const UNICHARSET &unicharset, GenericVector< UNICHAR_ID > *vec) const
bool end_of_word(EDGE_REF edge_ref) const
bool DeadEdge(const EDGE_RECORD &edge_rec) const
static const char kPuncPatternUnicode[]
static const char kAlphaPatternUnicode[]
virtual EDGE_REF pattern_loop_edge(EDGE_REF edge_ref, UNICHAR_ID unichar_id, bool word_end) const
int direction_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the direction flag of this edge.
UNICHAR_ID digit_pattern_
bool add_edge_linkage(NODE_REF node1, NODE_REF node2, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id)
static const char kDigitPatternUnicode[]
UNICHAR_ID edge_letter(EDGE_REF edge_ref) const
bool add_new_edge(NODE_REF node1, NODE_REF node2, bool repeats, bool word_end, UNICHAR_ID unichar_id)
bool end_of_word_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns true if this edge marks the end of a word.
static const char kLowerPatternUnicode[]
UNICHAR_ID unichar_id_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns UNICHAR_ID recorded in this edge.
void print_edge_rec(const EDGE_RECORD &edge_rec) const
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)
unsigned long long int uinT64
EDGE_REF edge_char_of(NODE_REF node_ref, UNICHAR_ID unichar_id, bool word_end) const
void link_edge(EDGE_RECORD *edge, NODE_REF nxt, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id)
void delete_data_pointers()
int direction(EDGEPT *point)
bool add_word_list(const GenericVector< STRING > &words, const UNICHARSET &unicharset)
UNICHAR_ID alphanum_pattern_
bool reduce_lettered_edges(EDGE_INDEX edge_index, UNICHAR_ID unichar_id, NODE_REF node, EDGE_VECTOR *backward_edges, NODE_MARKER reduced_nodes)
GenericVector< EDGE_RECORD > EDGE_VECTOR
static const char * get_reverse_policy_name(RTLReversePolicy reverse_policy)
NODE_REF next_node_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the next node visited by following this edge.
bool eliminate_redundant_edges(NODE_REF node, const EDGE_RECORD &edge1, const EDGE_RECORD &edge2)
SquishedDawg * trie_to_dawg()
void remove_edge(NODE_REF node1, NODE_REF node2, bool word_end, UNICHAR_ID unichar_id)
EDGE_VECTOR backward_edges
EDGE_REF make_edge_ref(NODE_REF node_index, EDGE_INDEX edge_index) const
bool initialized_patterns_
void init(DawgType type, const STRING &lang, PermuterType perm, int unicharset_size, int debug_level)
const STRING & lang() const
void reduce_node_input(NODE_REF node, NODE_MARKER reduced_nodes)
EDGE_VECTOR forward_edges
EDGE_RECORD * deref_edge_ref(EDGE_REF edge_ref) const
UNICHAR_ID lower_pattern_
GenericVector< EDGE_INDEX > root_back_freelist_
uinT64 deref_node_index_mask_
void sort_edges(EDGE_VECTOR *edges)
bool can_be_eliminated(const EDGE_RECORD &edge_rec)
void unichar_ids_of(NODE_REF node, NodeChildVector *vec, bool word_end) const