89 int unicharset_size,
int debug_level)
91 init(unicharset_size);
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;
248 bool word_end)
const {
249 if (edge_ref == NO_EDGE)
return NO_EDGE;
291 int edge_index =
static_cast<int>(
293 int node_index =
static_cast<int>(
327 return (node_ref != NO_EDGE &&
328 nodes_[static_cast<int>(node_ref)]->forward_edges.
size() == 1);
334 tprintf(
"\n__________________________\n%s\n", msg);
336 tprintf(
"__________________________\n");
356 bool repeats,
bool word_end,
UNICHAR_ID unichar_id) {
358 word_end, unichar_id) &&
360 word_end, unichar_id));
void initialize_patterns(UNICHARSET *unicharset)
UNICHAR_ID alphanum_pattern_
UNICHAR_ID alpha_pattern_
void remove_edge_linkage(NODE_REF node1, NODE_REF node2, int direction, bool word_end, UNICHAR_ID unichar_id)
EDGE_VECTOR forward_edges
GenericVector< EDGE_INDEX > root_back_freelist_
UNICHAR_ID upper_pattern_
void link_edge(EDGE_RECORD *edge, NODE_REF nxt, bool repeats, int direction, bool word_end, UNICHAR_ID unichar_id)
void KillEdge(EDGE_RECORD *edge_rec) const
void print_edge_rec(const EDGE_RECORD &edge_rec) const
int direction_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the direction flag of this edge.
UNICHAR_ID lower_pattern_
bool can_be_eliminated(const EDGE_RECORD &edge_rec)
void unichar_ids_of(NODE_REF node, NodeChildVector *vec, bool word_end) const
UNICHAR_ID unichar_id_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns UNICHAR_ID recorded in this edge.
static const char kDigitPatternUnicode[]
int direction(EDGEPT *point)
bool read_word_list(const char *filename, GenericVector< STRING > *words)
void unichar_id_to_patterns(UNICHAR_ID unichar_id, const UNICHARSET &unicharset, GenericVector< UNICHAR_ID > *vec) const
SquishedDawg * trie_to_dawg()
uint64_t deref_direction_mask_
EDGE_VECTOR backward_edges
bool add_word_to_dawg(const WERD_CHOICE &word, const GenericVector< bool > *repetitions)
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 * get_reverse_policy_name(RTLReversePolicy reverse_policy)
void sort_edges(EDGE_VECTOR *edges)
bool add_word_to_dawg(const WERD_CHOICE &word)
bool eliminate_redundant_edges(NODE_REF node, const EDGE_RECORD &edge1, const EDGE_RECORD &edge2)
EDGE_REF make_edge_ref(NODE_REF node_index, EDGE_INDEX edge_index) const
bool read_and_add_word_list(const char *filename, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse)
bool initialized_patterns_
bool end_of_word(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 marker_flag_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the marker flag of this edge.
DLLSYM void tprintf(const char *format,...)
static const char kAlphaPatternUnicode[]
bool add_word_list(const GenericVector< STRING > &words, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse_policy)
static const char kLowerPatternUnicode[]
static const char kAlphanumPatternUnicode[]
void remove_edge(NODE_REF node1, NODE_REF node2, bool word_end, UNICHAR_ID unichar_id)
void init(int unicharset_size)
void delete_data_pointers()
EDGE_RECORD * deref_edge_ref(EDGE_REF edge_ref) const
bool reduce_lettered_edges(EDGE_INDEX edge_index, UNICHAR_ID unichar_id, NODE_REF node, EDGE_VECTOR *backward_edges, NODE_MARKER reduced_nodes)
bool DeadEdge(const EDGE_RECORD &edge_rec) const
bool end_of_word_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns true if this edge marks the end of a word.
void print_node(NODE_REF node, int max_num_edges) const
const STRING & lang() const
UNICHAR_ID edge_letter(EDGE_REF edge_ref) const
uint64_t deref_node_index_mask_
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)
void reduce_node_input(NODE_REF node, NODE_MARKER reduced_nodes)
static const char kUpperPatternUnicode[]
NODE_REF next_node_from_edge_rec(const EDGE_RECORD &edge_rec) const
Returns the next node visited by following this edge.
UNICHAR_ID character_class_to_pattern(char ch)
EDGE_REF edge_char_of(NODE_REF node_ref, UNICHAR_ID unichar_id, bool word_end) const
void print_all(const char *msg, int max_num_edges)
virtual EDGE_REF pattern_loop_edge(EDGE_REF edge_ref, UNICHAR_ID unichar_id, bool word_end) const
bool read_pattern_list(const char *filename, const UNICHARSET &unicharset)
static const char kPuncPatternUnicode[]
NODE_REF next_node(EDGE_REF edge_ref) const
static const int kSaneNumConcreteChars