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
3
#include "
liblevenshtein/collection/prefix.h
"
4
5
6
namespace
liblevenshtein
{
7
8
Prefix::Prefix
(
DawgNode
* node,
Prefix
*
parent
,
char
label)
9
: _node(node),
10
_parent(
parent
),
11
_label(label)
12
{}
13
14
Prefix::Prefix
(
DawgNode
* root)
15
: _node(root),
16
_parent(
nullptr
),
17
_label(
'\0'
)
18
{}
19
20
Prefix::Prefix
(
Prefix
&&
prefix
)
noexcept
21
: _node(
prefix
._node),
22
_parent(
prefix
._parent),
23
_label(
prefix
._label)
24
{}
25
26
auto
Prefix::node
()
const
->
DawgNode
* {
27
return
_node
;
28
}
29
30
auto
Prefix::label
()
const
->
char
{
31
return
_label
;
32
}
33
34
auto
Prefix::str
()
const
->
std
::
string
{
35
std::stringstream
ss
;
36
ss
<< *
this
;
37
return
ss
.str();
38
}
39
40
auto
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
liblevenshtein::DawgNode
Represents a position within one or more terms of a DAWG dictionary.
Definition
dawg_node.h:20
liblevenshtein::Prefix
Represents the prefix of a dictionary term.
Definition
prefix.h:16
liblevenshtein::Prefix::_label
char _label
Current character label along the path from the root prefix node to this one.
Definition
prefix.h:92
liblevenshtein::Prefix::str
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
liblevenshtein::Prefix::Prefix
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
liblevenshtein::Prefix::label
auto label() const -> char
Returns the character label associated with this prefixed position within the dictionary term.
Definition
prefix.cpp:30
liblevenshtein::Prefix::node
auto node() const -> DawgNode *
Returns the node analogous to this prefix, within the dictionary.
Definition
prefix.cpp:26
liblevenshtein::Prefix::_node
DawgNode * _node
Analogous dictionary node to this prefix node.
Definition
prefix.h:85
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
liblevenshtein::operator<<
auto operator<<(std::ostream &out, const Dawg &dawg) -> std::ostream &
Definition
dawg.cpp:67
std
STL namespace.
prefix.h
src
liblevenshtein
collection
prefix.cpp
Generated by
1.10.0