liblevenshtein
4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
dawg_node.h
Go to the documentation of this file.
1
#ifndef LIBLEVENSHTEIN_COLLECTION_DAWG_NODE_H
2
#define LIBLEVENSHTEIN_COLLECTION_DAWG_NODE_H
3
4
#include <functional>
5
#include <map>
6
7
8
namespace
liblevenshtein
{
9
20
class
DawgNode
{
21
public
:
22
29
DawgNode
(
bool
is_final
=
false
);
30
38
DawgNode
(std::map<char, DawgNode *>&
edges
,
bool
is_final
=
false
);
39
46
void
is_final
(
bool
is_final
);
47
55
[[
nodiscard
]]
auto
is_final
()
const
->
bool
;
56
64
void
for_each_edge
(
const
std::function<
void
(
char
,
DawgNode
*)> &
fn
)
const
;
65
74
[[
nodiscard
]]
auto
transition
(
char
label)
const
->
DawgNode
*;
75
83
auto
add_edge
(
char
label,
DawgNode
*target) ->
DawgNode
*;
84
92
auto
operator==
(
const
DawgNode
&
other
)
const
->
bool
;
93
94
private
:
95
97
std::map<char, DawgNode *>
_edges
;
98
100
bool
_is_final
=
false
;
101
};
102
103
}
// namespace liblevenshtein
104
105
namespace
std
{
106
111
template
<>
112
struct
hash
<
liblevenshtein
::DawgNode> {
113
120
auto
operator()(
const
liblevenshtein::DawgNode
&node)
const
->
size_t
;
121
};
122
123
}
// namespace std
124
125
#endif
// LIBLEVENSHTEIN_COLLECTION_DAWG_NODE_H
liblevenshtein::DawgNode
Represents a position within one or more terms of a DAWG dictionary.
Definition
dawg_node.h:20
liblevenshtein::DawgNode::_edges
std::map< char, DawgNode * > _edges
Outgoing edges from this node.
Definition
dawg_node.h:97
liblevenshtein::DawgNode::_is_final
bool _is_final
Whether this node represents a word boundary.
Definition
dawg_node.h:100
liblevenshtein::DawgNode::operator==
auto operator==(const DawgNode &other) const -> bool
Determines whether this node is equivalent to another.
Definition
dawg_node.cpp:53
liblevenshtein::DawgNode::is_final
auto is_final() const -> bool
Declares whether this node represents a word boundary, or whether it immediately follows an edge havi...
Definition
dawg_node.cpp:23
liblevenshtein::DawgNode::for_each_edge
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...
Definition
dawg_node.cpp:27
liblevenshtein::DawgNode::add_edge
auto add_edge(char label, DawgNode *target) -> DawgNode *
Adds a new outgoing edge to this node.
Definition
dawg_node.cpp:41
liblevenshtein::DawgNode::transition
auto transition(char label) const -> DawgNode *
Returns the target node, following this one, along the edge annotated with the given label.
Definition
dawg_node.cpp:33
liblevenshtein::DawgNode::DawgNode
DawgNode(bool is_final=false)
Constructs a new DAWG node with an optional parameter that determines whether it is final (i....
Definition
dawg_node.cpp:15
query
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition
main.cpp:25
liblevenshtein
Various utilities regarding Levenshtein transducers.
Definition
namespaces.dox:9
std
STL namespace.
src
liblevenshtein
collection
dawg_node.h
Generated by
1.10.0