liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
position.h
Go to the documentation of this file.
1#ifndef LIBLEVENSHTEIN_TRANSDUCER_POSITION_H
2#define LIBLEVENSHTEIN_TRANSDUCER_POSITION_H
3
4#include <cstddef>
5
6namespace liblevenshtein {
7
11class Position {
12public:
13
22 Position(std::size_t term_index, std::size_t num_errors,
23 bool is_special = false);
24
28 ~Position();
29
35 void next(Position *next);
36
42 [[nodiscard]] auto next() const -> Position *;
43
49 [[nodiscard]] auto term_index() const -> std::size_t;
50
56 [[nodiscard]] auto num_errors() const -> std::size_t;
57
63 [[nodiscard]] auto is_special() const -> bool;
64
65private:
66
68 Position *_next = nullptr;
69
71 std::size_t _term_index;
72
75 std::size_t _num_errors;
76
79};
80
81} // namespace liblevenshtein
82
83#endif // LIBLEVENSHTEIN_TRANSDUCER_POSITION_H
Represents a location within the Levenshtein automaton.
Definition position.h:11
std::size_t _term_index
The current position within the dictionary term.
Definition position.h:71
~Position()
Frees any owned allocations.
Definition position.cpp:11
auto next() const -> Position *
Returns the Position that follows this one along the current path.
Definition position.cpp:19
auto term_index() const -> std::size_t
Returns the current position in the dictionary term.
Definition position.cpp:23
Position * _next
The Position that follows this one along the current path.
Definition position.h:68
auto is_special() const -> bool
Returns whether this is a special state of one of the extended algorithms.
Definition position.cpp:31
auto num_errors() const -> std::size_t
Returns the accumulated number of errors at the term_index.
Definition position.cpp:27
std::size_t _num_errors
The accumulated number of errors between the spelling candidate and query term, at term_index of the ...
Definition position.h:75
Position(std::size_t term_index, std::size_t num_errors, bool is_special=false)
Constructs a new Position within the Levenshtein automaton.
Definition position.cpp:5
bool _is_special
Whether this is a special state of one of the extended algorithms.
Definition position.h:78
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