liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
prefix.cpp
Go to the documentation of this file.
1#include <sstream>
2
4
5
6namespace liblevenshtein {
7
8Prefix::Prefix(DawgNode* node, Prefix *parent, char label)
9 : _node(node),
10 _parent(parent),
11 _label(label)
12{}
13
15 : _node(root),
16 _parent(nullptr),
17 _label('\0')
18{}
19
21 : _node(prefix._node),
22 _parent(prefix._parent),
23 _label(prefix._label)
24{}
25
27 return _node;
28}
29
30auto Prefix::label() const -> char {
31 return _label;
32}
33
34auto Prefix::str() const -> std::string {
35 std::stringstream ss;
36 ss << *this;
37 return ss.str();
38}
39
40auto operator<<(std::ostream &out, const Prefix &prefix) -> std::ostream & {
41 if (prefix._parent != nullptr) {
42 out << *(prefix._parent) << prefix._label;
43 }
44 return out;
45}
46
47} // namespace liblevenshtein
Represents a position within one or more terms of a DAWG dictionary.
Definition dawg_node.h:20
Represents the prefix of a dictionary term.
Definition prefix.h:16
char _label
Current character label along the path from the root prefix node to this one.
Definition prefix.h:92
auto str() const -> std::string
Returns the string constructed by following the path between the root prefix node and this one,...
Definition prefix.cpp:34
Prefix(DawgNode *node, Prefix *parent, char label)
Constructs a new prefix that follows another along the path from the root node to the current one.
Definition prefix.cpp:8
auto label() const -> char
Returns the character label associated with this prefixed position within the dictionary term.
Definition prefix.cpp:30
auto node() const -> DawgNode *
Returns the node analogous to this prefix, within the dictionary.
Definition prefix.cpp:26
DawgNode * _node
Analogous dictionary node to this prefix node.
Definition prefix.h:85
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25
Various utilities regarding Levenshtein transducers.
Definition namespaces.dox:9
auto operator<<(std::ostream &out, const Dawg &dawg) -> std::ostream &
Definition dawg.cpp:67
STL namespace.