liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
liblevenshtein::Transducer< Type, Result > Class Template Reference

Constructs a Levenshtein Transducer that, when given a dictionary automaton, query term, and maximum edit distance, n, is able to match all spelling candidates in the dictionary automaton for the query term whose edit distances are no larger than n. More...

#include <transducer.h>

Collaboration diagram for liblevenshtein::Transducer< Type, Result >:

Public Member Functions

 Transducer (DawgNode *root)
 Constructs a Levenshtein Transducer around the root DawgNode of a Dawg dictionary.
 
 ~Transducer ()
 Frees any owned allocations.
 
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 dictionary automaton whose edit distances from term are no greater than max_distance.
 

Private Attributes

Intersection_intersection
 Initial intersection between the Levenshtein automaton and dictionary automaton.
 

Detailed Description

template<Algorithm Type, class Result>
class liblevenshtein::Transducer< Type, Result >

Constructs a Levenshtein Transducer that, when given a dictionary automaton, query term, and maximum edit distance, n, is able to match all spelling candidates in the dictionary automaton for the query term whose edit distances are no larger than n.

Definition at line 26 of file transducer.h.

Constructor & Destructor Documentation

◆ Transducer()

template<Algorithm Type, class Result >
liblevenshtein::Transducer< Type, Result >::Transducer ( DawgNode * root)

Constructs a Levenshtein Transducer around the root DawgNode of a Dawg dictionary.

Parameters
rootRoot DawgNode for some Dawg dictionary.

Definition at line 14 of file transducer.cpp.

14 {
15 auto *position = new Position(0, 0);
16 auto *initial_state = new State({position});
17 _intersection = new Intersection('\0', root, initial_state);
18}
Intersection * _intersection
Initial intersection between the Levenshtein automaton and dictionary automaton.
Definition transducer.h:61
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25

References query().

Here is the call graph for this function:

◆ ~Transducer()

Frees any owned allocations.

Definition at line 21 of file transducer.cpp.

21 {
22 delete _intersection;
23}

Member Function Documentation

◆ operator()()

template<Algorithm Type, class Result >
auto liblevenshtein::Transducer< Type, Result >::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 dictionary automaton whose edit distances from term are no greater than max_distance.

Parameters
termQuery term for spelling correction.
max_distanceMaximum edit distance to consider when matching spelling candidates.
Returns
An iterator over the spelling candidates from the dictionary automaton whose edit distances from term are no greater than max_distance.

Definition at line 26 of file transducer.cpp.

28 {
30 term, max_distance, _intersection,
32 merge<Type>, UnsubsumeFn(subsumes<Type>),
33 max_distance, term.length()),
35}

References query().

Here is the call graph for this function:

Member Data Documentation

◆ _intersection

template<Algorithm Type, class Result >
Intersection* liblevenshtein::Transducer< Type, Result >::_intersection
private

Initial intersection between the Levenshtein automaton and dictionary automaton.

Definition at line 61 of file transducer.h.


The documentation for this class was generated from the following files: