liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
state_transition.h
Go to the documentation of this file.
1#ifndef LIBLEVENSHTEIN_TRANSDUCER_STATE_TRANSITION_H
2#define LIBLEVENSHTEIN_TRANSDUCER_STATE_TRANSITION_H
3
4#include <cstddef>
5#include <functional>
6#include <vector>
7
11
12namespace liblevenshtein {
13
16 std::function<std::vector<Position *>(std::size_t, Position *,
17 std::vector<bool>&, std::size_t)>;
18
20using CompareFn = std::function<int(Position *, Position *)>;
21
23using MergeFn = std::function<void(State *, std::vector<Position *>)>;
24
29public:
30
48 std::size_t max_distance,
49 std::size_t query_length);
50
60 auto operator()(State *curr_state, std::vector<bool> &characteristic_vector)
61 -> State *;
62
63private:
64
68
71
74
78
80 std::size_t max_distance;
81
83 std::size_t query_length;
84};
85
86} // namespace liblevenshtein
87
88#endif // LIBLEVENSHTEIN_TRANSDUCER_STATE_TRANSITION_H
Represents a location within the Levenshtein automaton.
Definition position.h:11
Transitions Levenshtein States given a characteristic vector.
UnsubsumeFn unsubsume
Removes redundant Positions from a State according to the notion of subsumption.
StateTransition(PositionTransitionFn transition, CompareFn compare, MergeFn merge, UnsubsumeFn unsubsume, std::size_t max_distance, std::size_t query_length)
Constructs a new StateTransition function.
MergeFn merge
Merges Positions into a State.
PositionTransitionFn transition
Maps Position nodes and characteristic vectors to subsequent Position nodes.
auto operator()(State *curr_state, std::vector< bool > &characteristic_vector) -> State *
Returns a successive State to the current one given the characteristic vector.
std::size_t query_length
Length of the query term.
std::size_t max_distance
Maximum edit distance to consider when matching spelling candidates.
CompareFn compare
Compares Position nodes.
Consists of a closure of Position nodes within the Levenshtein automaton.
Definition state.h:23
Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same...
Definition unsubsume.h:20
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
std::function< int(Position *, Position *)> CompareFn
Compares Position nodes.
std::function< std::vector< Position * >(std::size_t, Position *, std::vector< bool > &, std::size_t)> PositionTransitionFn
Transitions Position nodes.
std::function< void(State *, std::vector< Position * >)> MergeFn
Merges Position nodes into a State.