liblevenshtein
4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
sorted_dawg.h
Go to the documentation of this file.
1
#ifndef LIBLEVENSHTEIN_COLLECTION_SORTED_DAWG_H
2
#define LIBLEVENSHTEIN_COLLECTION_SORTED_DAWG_H
3
4
#include <stack>
5
#include <unordered_map>
6
#include <unordered_set>
7
8
#include "
liblevenshtein/collection/dawg.h
"
9
#include "
liblevenshtein/collection/dawg_node.h
"
10
#include "
liblevenshtein/collection/transition.h
"
11
12
namespace
liblevenshtein
{
13
20
class
SortedDawg
:
public
Dawg
{
21
public
:
22
using
Dawg::Dawg
;
23
28
~SortedDawg
()
override
;
29
37
auto
add
(
const
std::string &
term
) ->
bool
override
;
38
46
auto
remove
(
const
std::string &
term
) ->
bool
override
;
47
52
void
init
();
53
57
void
clean_up
();
58
63
void
finish
();
64
73
void
minimize
(std::size_t
lower_bound
);
74
84
auto
minimized_node
(
DawgNode
*
key
)
const
->
DawgNode
*;
85
86
private
:
87
89
std::stack<Transition> *
unchecked_transitions
=
nullptr
;
90
92
std::unordered_map<DawgNode, DawgNode *> *
minimized_nodes
=
nullptr
;
93
95
std::unordered_set<DawgNode *> *
floating_nodes
=
nullptr
;
96
98
std::string
_prev_term
;
99
};
100
109
template
<
class
IterType>
110
auto
sorted_dawg
(
IterType
iter
,
IterType
end) ->
SortedDawg
*;
111
112
}
// namespace liblevenshtein
113
114
#endif
// LIBLEVENSHTEIN_COLLECTION_SORTED_DAWG_H
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::Dawg
Dawg()
Constructs an empty DAWG with a default root node (there are no outgoing edges or reachable terms fro...
Definition
dawg.cpp:17
liblevenshtein::SortedDawg
A specific type of Dawg that is constructed over lexicographically sorted terms.
Definition
sorted_dawg.h:20
liblevenshtein::SortedDawg::floating_nodes
std::unordered_set< DawgNode * > * floating_nodes
Nodes that have not been added to this Dawg.
Definition
sorted_dawg.h:95
liblevenshtein::SortedDawg::~SortedDawg
~SortedDawg() override
Cleans up any residual intermediate members used to construct the Dawg.
Definition
sorted_dawg.cpp:11
liblevenshtein::SortedDawg::add
auto add(const std::string &term) -> bool override
Adds a new term to this dictionary.
Definition
sorted_dawg.cpp:15
liblevenshtein::SortedDawg::minimized_node
auto minimized_node(DawgNode *key) const -> DawgNode *
Returns a DawgNode whose following suffix is equivalent to the following suffix of the given DawgNode...
Definition
sorted_dawg.cpp:61
liblevenshtein::SortedDawg::minimized_nodes
std::unordered_map< DawgNode, DawgNode * > * minimized_nodes
Mapping of suffixes to DawgNodes that have been minimized.
Definition
sorted_dawg.h:92
liblevenshtein::SortedDawg::remove
auto remove(const std::string &term) -> bool override
Removes a term from this dictionary.
Definition
sorted_dawg.cpp:88
liblevenshtein::SortedDawg::_prev_term
std::string _prev_term
Previous term inserted into this Dawg.
Definition
sorted_dawg.h:98
liblevenshtein::SortedDawg::minimize
void minimize(std::size_t lower_bound)
Minimizes the suffixes of the unchecked paths until there are no more than lower_bound unchecked tran...
Definition
sorted_dawg.cpp:69
liblevenshtein::SortedDawg::init
void init()
Prepares this dictionary for initialization.
Definition
sorted_dawg.cpp:92
liblevenshtein::SortedDawg::finish
void finish()
Specifies the dictionary has been fully initialized.
Definition
sorted_dawg.cpp:57
liblevenshtein::SortedDawg::clean_up
void clean_up()
Cleans up any intermediate members used to initialize this Dawg.
Definition
sorted_dawg.cpp:98
liblevenshtein::SortedDawg::unchecked_transitions
std::stack< Transition > * unchecked_transitions
Transitions whose redundancies have not been checked.
Definition
sorted_dawg.h:89
dawg.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
liblevenshtein::sorted_dawg
auto sorted_dawg(IterType iter, IterType end) -> SortedDawg *
Factory function that initializes a new SortedDawg using the terms yielded from an iterator.
Definition
sorted_dawg.cpp:124
transition.h
src
liblevenshtein
collection
sorted_dawg.h
Generated by
1.10.0