liblevenshtein
4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
dawg.h
Go to the documentation of this file.
1
#ifndef LIBLEVENSHTEIN_COLLECTION_DAWG_H
2
#define LIBLEVENSHTEIN_COLLECTION_DAWG_H
3
4
#include <iostream>
5
#include <string>
6
#include <unordered_set>
7
8
#include "
liblevenshtein/collection/dawg_iterator.h
"
9
#include "
liblevenshtein/collection/dawg_node.h
"
10
11
namespace
liblevenshtein
{
12
23
class
Dawg
{
24
public
:
25
35
Dawg
(
DawgNode
*
root
, std::size_t
size
);
36
41
Dawg
();
42
46
virtual
~Dawg
();
47
55
virtual
auto
add
(
const
std::string &
term
) ->
bool
= 0;
56
63
virtual
auto
remove
(
const
std::string &
term
) ->
bool
= 0;
64
72
[[
nodiscard
]]
auto
contains
(
const
std::string &
term
)
const
->
bool
;
73
80
[[
nodiscard
]]
auto
root
()
const
->
DawgNode
*;
81
87
[[
nodiscard
]]
auto
size
()
const
->
size_t
;
88
95
[[
nodiscard
]]
auto
begin
()
const
->
DawgIterator
;
96
105
[[
nodiscard
]]
auto
end
()
const
->
DawgIterator
;
106
113
auto
operator
==(
const
Dawg
&
other
)
const
->
bool
;
114
116
friend
class
std
::
hash
<
Dawg
>;
117
120
friend
auto
operator
<<(
std
::ostream &
out
,
const
Dawg
&
dawg
)
121
->
std
::ostream &;
122
123
protected
:
124
126
DawgNode
*
_root
;
127
129
std
::
size_t
_size
;
130
136
[[
nodiscard
]]
auto
all_nodes
()
const
->
std
::unordered_set<
DawgNode
*>;
137
};
138
139
}
// namespace liblevenshtein
140
141
142
namespace
std
{
143
150
template
<>
151
struct
hash
<
liblevenshtein
::
Dawg
> {
152
159
auto
operator()(
const
liblevenshtein::Dawg
&
dawg
)
const
->
size_t
;
160
};
161
}
// namespace std
162
163
164
#endif
// LIBLEVENSHTEIN_COLLECTION_DAWG_H
liblevenshtein::DawgIterator
Iterates over all the terms in a DAWG dictionary.
Definition
dawg_iterator.h:15
liblevenshtein::DawgNode
Represents a position within one or more terms of a DAWG dictionary.
Definition
dawg_node.h:20
liblevenshtein::Dawg
A Directed Acyclic Word Graph (DAWG) maps sequences of characters to form words; the collection of wo...
Definition
dawg.h:23
liblevenshtein::Dawg::remove
virtual auto remove(const std::string &term) -> bool=0
Removes a term from this dictionary and cleans up its path.
liblevenshtein::Dawg::contains
auto contains(const std::string &term) const -> bool
Determines whether the given term is contained within this dictionary.
Definition
dawg.cpp:43
liblevenshtein::Dawg::_size
std::size_t _size
Number of terms reachable from the root node.
Definition
dawg.h:129
liblevenshtein::Dawg::root
auto root() const -> DawgNode *
Returns a pointer to the root node of this dictionary from which all its terms may be determined.
Definition
dawg.cpp:51
liblevenshtein::Dawg::all_nodes
auto all_nodes() const -> std::unordered_set< DawgNode * >
Returns a set of all nodes reachable from the root, including the root.
Definition
dawg.cpp:28
liblevenshtein::Dawg::_root
DawgNode * _root
Root node of this DAWG from which all its terms may be reached.
Definition
dawg.h:126
liblevenshtein::Dawg::begin
auto begin() const -> DawgIterator
Returns an iterator pointing to the first term in this dictionary, from which all terms may be iterat...
Definition
dawg.cpp:59
liblevenshtein::Dawg::~Dawg
virtual ~Dawg()
Deletes all the nodes associated with this dictionary.
Definition
dawg.cpp:22
liblevenshtein::Dawg::end
auto end() const -> DawgIterator
Returns an iterator representing the boundary following the final term in this dictionary.
Definition
dawg.cpp:63
liblevenshtein::Dawg::size
auto size() const -> size_t
Returns the number of terms in this dictionary.
Definition
dawg.cpp:55
liblevenshtein::Dawg::add
virtual auto add(const std::string &term) -> bool=0
Adds a new term to this dictionary by adding missing sequential edges leading outward from the root n...
liblevenshtein::Dawg::Dawg
Dawg()
Constructs an empty DAWG with a default root node (there are no outgoing edges or reachable terms fro...
Definition
dawg.cpp:17
dawg_iterator.h
dawg_node.h
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.h
Generated by
1.10.0