liblevenshtein
4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
transducer.cpp
Go to the documentation of this file.
1
#include "
liblevenshtein/transducer/transducer.h
"
2
#include "
liblevenshtein/transducer/comparator.h
"
3
#include "
liblevenshtein/transducer/distance.h
"
4
#include "
liblevenshtein/transducer/merge.h
"
5
#include "
liblevenshtein/transducer/position.h
"
6
#include "
liblevenshtein/transducer/position_transition.h
"
7
#include "
liblevenshtein/transducer/state_transition.h
"
8
#include "
liblevenshtein/transducer/subsumes.h
"
9
#include "
liblevenshtein/transducer/unsubsume.h
"
10
11
namespace
liblevenshtein
{
12
13
template
<Algorithm Type,
class
Result>
14
Transducer<Type, Result>::Transducer
(
DawgNode
*root) {
15
auto
*
position
=
new
Position
(0, 0);
16
auto
*
initial_state
=
new
State
({
position
});
17
_intersection =
new
Intersection
(
'\0'
, root,
initial_state
);
18
}
19
20
template
<Algorithm Type,
class
Result>
21
Transducer<Type, Result>::~Transducer
() {
22
delete
_intersection;
23
}
24
25
template
<Algorithm Type,
class
Result>
26
auto
Transducer<Type, Result>::operator()
(
const
std::string &
term
,
27
std::size_t max_distance)
28
->
LazyIterator<Result>
{
29
return
LazyIterator<Result>
(
30
term
, max_distance, _intersection,
31
StateTransition
(
position_transition<Type>
,
compare<Type>
,
32
merge<Type>
,
UnsubsumeFn
(
subsumes<Type>
),
33
max_distance,
term
.length()),
34
distance<Type>
);
35
}
36
37
template
class
Transducer<Algorithm::STANDARD, std::string>
;
38
template
class
Transducer<Algorithm::STANDARD, Candidate>
;
39
template
class
Transducer<Algorithm::TRANSPOSITION, std::string>
;
40
template
class
Transducer<Algorithm::TRANSPOSITION, Candidate>
;
41
template
class
Transducer<Algorithm::MERGE_AND_SPLIT, std::string>
;
42
template
class
Transducer<Algorithm::MERGE_AND_SPLIT, Candidate>
;
43
44
}
// namespace liblevenshtein
liblevenshtein::DawgNode
Represents a position within one or more terms of a DAWG dictionary.
Definition
dawg_node.h:20
liblevenshtein::Intersection
Represents an Intersection between a dictionary automaton and Levenshtein automaton,...
Definition
intersection.h:16
liblevenshtein::LazyIterator
Lazily traverses the intersection between the dictionary automaton and Levenshtein automaton,...
Definition
lazy_query.h:180
liblevenshtein::Position
Represents a location within the Levenshtein automaton.
Definition
position.h:11
liblevenshtein::StateTransition
Transitions Levenshtein States given a characteristic vector.
Definition
state_transition.h:28
liblevenshtein::State
Consists of a closure of Position nodes within the Levenshtein automaton.
Definition
state.h:23
liblevenshtein::Transducer
Constructs a Levenshtein Transducer that, when given a dictionary automaton, query term,...
Definition
transducer.h:26
liblevenshtein::Transducer::~Transducer
~Transducer()
Frees any owned allocations.
Definition
transducer.cpp:21
liblevenshtein::Transducer::operator()
auto operator()(const std::string &term, std::size_t max_distance=2) -> LazyIterator< Result >
Transduces the query term and max_distance into the set of all spelling candidates from the dictionar...
Definition
transducer.cpp:26
liblevenshtein::Transducer::Transducer
Transducer(DawgNode *root)
Constructs a Levenshtein Transducer around the root DawgNode of a Dawg dictionary.
Definition
transducer.cpp:14
liblevenshtein::UnsubsumeFn
Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same...
Definition
unsubsume.h:20
comparator.h
query
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition
main.cpp:25
merge.h
liblevenshtein
Various utilities regarding Levenshtein transducers.
Definition
namespaces.dox:9
position.h
position_transition.h
state_transition.h
subsumes.h
distance.h
transducer.h
unsubsume.h
src
liblevenshtein
transducer
transducer.cpp
Generated by
1.10.0