1#ifndef LIBLEVENSHTEIN_TRANSDUCER_LAZY_QUERY_H
2#define LIBLEVENSHTEIN_TRANSDUCER_LAZY_QUERY_H
172 std::
size_t i) ->
std::vector<
bool>;
Represents a position within one or more terms of a DAWG dictionary.
Represents an Intersection between a dictionary automaton and Levenshtein automaton,...
Lazily traverses the intersection between the dictionary automaton and Levenshtein automaton,...
TransitionFn transition
Maps one Levenshtein State to another given the state and a characteristic vector.
std::size_t _max_distance
Maximum edit distance to consider when matching spelling candidates.
Intersection * _intersection
Initial Intersection between the dictionary root node and initial Levenshtein State.
std::string _term
Query term whose spelling candidates are to be matched.
DistanceFn min_distance
Infers the Levenshtein distance between the query term and a spelling candidate.
Lazily traverses the intersection between the dictionary automaton and Levenshtein automaton,...
Result _candidate
Presently matched spelling candidate.
void advance()
Advances to the next spelling candidate.
std::size_t _a
Intermediate value used to compare edit distances without overflowing.
TransitionFn transition
Maps one Levenshtein State to another given the State and a characteristic vector.
std::size_t _k
Intermediate value used to compare edit distances without overflowing.
std::queue< Intersection * > _pending
Intermediate Intersection instances representing paths along the intersection between the dictionary ...
Intersection * _intersection
Current whose respective spelling candidates are being considered.
auto characteristic_vector(char x, std::string &term, std::size_t k, std::size_t i) -> std::vector< bool >
Flags all instances of the given character in the query term within a window of consecutive character...
std::size_t _max_distance
Maximum edit distance to consider when matching spelling candidates.
std::string _term
Query term whose spelling candidates are to be matched.
auto operator++() -> LazyQuery &
Advances to the next spelling candidate.
LazyQuery()=default
Constructs a LazyQuery that represents the end of the spelling candidates.
auto build_intersection(char label, DawgNode *node, State *state, Intersection *parent) -> Intersection *
Factory function that constructs and records a new Intersection instance.
std::queue< std::pair< char, DawgNode * > > _edges
Outgoing dictionary node edges that are pending traversal along the intersection between the dictiona...
std::vector< Intersection * > _intersections
Tracks Intersection allocations so they may be freed.
DistanceFn min_distance
Infers the Levenshtein distance between the query term and a spelling candidate.
auto operator*() const -> const Result &
Returns the current spelling candidate.
bool _is_complete
Whether all the spelling candidates have been matched.
void update_candidate(std::string &term, std::size_t distance)
Sets the current spelling candidate according to the desired Result type.
~LazyQuery()
Frees any owned members.
std::size_t _i
Intermediate value used to compare edit distances without overflowing.
Consists of a closure of Position nodes within the Levenshtein automaton.
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Various utilities regarding Levenshtein transducers.
std::function< std::size_t(State *, std::size_t)> DistanceFn
Infers the Levenshtein distance from a final Levenshtein State and the length of the query term.
std::function< State *(State *, std::vector< bool > &)> TransitionFn
Returns the Levenshtein State mapped-to by another State and characteristic vector.