liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
|
Represents a position within one or more terms of a DAWG dictionary. More...
#include <dawg_node.h>
Public Member Functions | |
DawgNode (bool is_final=false) | |
Constructs a new DAWG node with an optional parameter that determines whether it is final (i.e. | |
DawgNode (std::map< char, DawgNode * > &edges, bool is_final=false) | |
Constructs a new DAWG node with an initial mapping of outgoing edges and whether it represents a word boundary. | |
void | is_final (bool is_final) |
Specifies whether this node represents a word boundary, or immediately follows an edge having the final character of a dictionary term. | |
auto | is_final () const -> bool |
Declares whether this node represents a word boundary, or whether it immediately follows an edge having the final character of a dictionary term. | |
void | for_each_edge (const std::function< void(char, DawgNode *)> &fn) const |
Iterates over each outgoing edge of this node and invokes a callback function with each edge's character label and target node. | |
auto | transition (char label) const -> DawgNode * |
Returns the target node, following this one, along the edge annotated with the given label. | |
auto | add_edge (char label, DawgNode *target) -> DawgNode * |
Adds a new outgoing edge to this node. | |
auto | operator== (const DawgNode &other) const -> bool |
Determines whether this node is equivalent to another. | |
Private Attributes | |
std::map< char, DawgNode * > | _edges |
Outgoing edges from this node. | |
bool | _is_final = false |
Whether this node represents a word boundary. | |
Represents a position within one or more terms of a DAWG dictionary.
The position range from before the first character to after the last one, of each term. The terms' consecutive characters are recorded as labels along the edges between the nodes. The terms may be reconstructed by traversing the outgoing edges from the root node of the dictionary and collecting the consecutive character labels along each path. Each path constructed by following the consecutive outgoing edges from the root node to final nodes forms a term in the dictionary.
Definition at line 20 of file dawg_node.h.
Constructs a new DAWG node with an optional parameter that determines whether it is final (i.e.
whether it is a word boundary).
is_final | Whether this node represents a word boundary. |
Definition at line 15 of file dawg_node.cpp.
Constructs a new DAWG node with an initial mapping of outgoing edges and whether it represents a word boundary.
edges | Mapping of outgoing edges from this node. |
is_final | Whether this node represents a word boundary. |
Definition at line 10 of file dawg_node.cpp.
Adds a new outgoing edge to this node.
label | Annotation for the outgoing edge. |
target | Destination node for the outgoing edge. |
Definition at line 41 of file dawg_node.cpp.
References query().
Referenced by liblevenshtein::from_protobuf(), and liblevenshtein::SortedDawg::minimize().
void liblevenshtein::DawgNode::for_each_edge | ( | const std::function< void(char, DawgNode *)> & | fn | ) | const |
Iterates over each outgoing edge of this node and invokes a callback function with each edge's character label and target node.
fn | Callback function to invoke with each edge's character label and target node. |
Definition at line 27 of file dawg_node.cpp.
References _edges, and query().
Referenced by liblevenshtein::DawgIterator::advance(), liblevenshtein::LazyQuery< Result >::advance(), liblevenshtein::collect_edges(), and liblevenshtein::collect_nodes().
Declares whether this node represents a word boundary, or whether it immediately follows an edge having the final character of a dictionary term.
Definition at line 23 of file dawg_node.cpp.
References _is_final.
Referenced by is_final().
Specifies whether this node represents a word boundary, or immediately follows an edge having the final character of a dictionary term.
is_final | Whether this node represents a word boundary. |
Definition at line 19 of file dawg_node.cpp.
References _is_final, and is_final().
Referenced by liblevenshtein::SortedDawg::add(), liblevenshtein::DawgIterator::advance(), liblevenshtein::collect_nodes(), liblevenshtein::Dawg::contains(), and liblevenshtein::LazyQuery< Result >::LazyQuery().
Determines whether this node is equivalent to another.
other | Candidate node whose equivalence to this one is to be computed. |
Definition at line 53 of file dawg_node.cpp.
References query(), and transition().
Returns the target node, following this one, along the edge annotated with the given label.
If no such edge exists, nullptr is returned.
label | Outgoing edge label whose target is desired. |
Definition at line 33 of file dawg_node.cpp.
References query().
Referenced by liblevenshtein::Dawg::contains(), and operator==().
Outgoing edges from this node.
Definition at line 97 of file dawg_node.h.
Referenced by for_each_edge().
Whether this node represents a word boundary.
Definition at line 100 of file dawg_node.h.
Referenced by is_final(), and is_final().