5#include "MurmurHash2.h"
29 std::unordered_set<DawgNode *>
nodes;
45 for (
int i = 0;
i <
term.length() && node !=
nullptr;
i += 1) {
48 return node !=
nullptr && node->
is_final();
68 out <<
"Dawg{size=" <<
dawg._size <<
", root=" <<
dawg._root <<
"}";
73 return size() ==
other.size() && *root() == *
other.root();
81auto std::hash<liblevenshtein::Dawg>::operator()(
86 std::array<uint64_t, 1>
key = {
dawg._size};
Iterates over all the terms in a DAWG dictionary.
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...
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 charac...
auto transition(char label) const -> DawgNode *
Returns the target node, following this one, along the edge annotated with the given label.
A Directed Acyclic Word Graph (DAWG) maps sequences of characters to form words; the collection of wo...
auto operator==(const Dawg &other) const -> bool
Determines whether another DAWG is equivalent to this one.
auto contains(const std::string &term) const -> bool
Determines whether the given term is contained within this dictionary.
std::size_t _size
Number of terms reachable from the root node.
auto root() const -> DawgNode *
Returns a pointer to the root node of this dictionary from which all its terms may be determined.
auto all_nodes() const -> std::unordered_set< DawgNode * >
Returns a set of all nodes reachable from the root, including the root.
DawgNode * _root
Root node of this DAWG from which all its terms may be reached.
auto begin() const -> DawgIterator
Returns an iterator pointing to the first term in this dictionary, from which all terms may be iterat...
virtual ~Dawg()
Deletes all the nodes associated with this dictionary.
auto end() const -> DawgIterator
Returns an iterator representing the boundary following the final term in this dictionary.
auto size() const -> size_t
Returns the number of terms in this dictionary.
Dawg()
Constructs an empty DAWG with a default root node (there are no outgoing edges or reachable terms fro...
static std::hash< liblevenshtein::DawgNode > node_hash_code
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Various utilities regarding Levenshtein transducers.
auto operator<<(std::ostream &out, const Dawg &dawg) -> std::ostream &