16 if (
term < _prev_term) {
21 _root->is_final(
true);
40 DawgNode *source = unchecked_transitions->empty()
42 : unchecked_transitions->top().target();
44 for (std::size_t
k =
term.length();
i <
k;
i += 1) {
46 floating_nodes->insert(target);
47 unchecked_transitions->emplace(
term[
i], source, target);
62 auto iter = minimized_nodes->find(*
key);
63 if (
iter != minimized_nodes->end()) {
74 char label = transition.
label();
83 (*minimized_nodes)[*target] = target;
123template <
class IterType>
128 while (
iter != end) {
144 std::list<std::string>::iterator end) ->
SortedDawg *;
148 std::vector<std::string>::iterator end) ->
SortedDawg *;
152 std::set<std::string>::iterator end) ->
SortedDawg *;
Represents a position within one or more terms of a DAWG dictionary.
void is_final(bool is_final)
Specifies whether this node represents a word boundary, or immediately follows an edge having the fin...
auto add_edge(char label, DawgNode *target) -> DawgNode *
Adds a new outgoing edge to this node.
auto all_nodes() const -> std::unordered_set< DawgNode * >
Returns a set of all nodes reachable from the root, including the root.
A specific type of Dawg that is constructed over lexicographically sorted terms.
std::unordered_set< DawgNode * > * floating_nodes
Nodes that have not been added to this Dawg.
~SortedDawg() override
Cleans up any residual intermediate members used to construct the Dawg.
auto add(const std::string &term) -> bool override
Adds a new term to this dictionary.
auto minimized_node(DawgNode *key) const -> DawgNode *
Returns a DawgNode whose following suffix is equivalent to the following suffix of the given DawgNode...
std::unordered_map< DawgNode, DawgNode * > * minimized_nodes
Mapping of suffixes to DawgNodes that have been minimized.
auto remove(const std::string &term) -> bool override
Removes a term from this dictionary.
void minimize(std::size_t lower_bound)
Minimizes the suffixes of the unchecked paths until there are no more than lower_bound unchecked tran...
void init()
Prepares this dictionary for initialization.
void finish()
Specifies the dictionary has been fully initialized.
void clean_up()
Cleans up any intermediate members used to initialize this Dawg.
std::stack< Transition > * unchecked_transitions
Transitions whose redundancies have not been checked.
Represents an edge from one DawgNode to another, annotated with a character label from the current po...
auto source() const -> DawgNode *
Returns the initial DawgNode along the edge of this transition.
auto label() const -> char
Returns the label annotating the edge from the source to the target of this Transition.
auto target() const -> DawgNode *
Returns the destination DawgNode along the edge of this transition.
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Various utilities regarding Levenshtein transducers.
auto sorted_dawg(IterType iter, IterType end) -> SortedDawg *
Factory function that initializes a new SortedDawg using the terms yielded from an iterator.