liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
liblevenshtein::UnsubsumeFn Class Reference

Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same State. More...

#include <unsubsume.h>

Collaboration diagram for liblevenshtein::UnsubsumeFn:

Public Member Functions

 UnsubsumeFn (SubsumesFn subsumes)
 Constructs a new UnsubsumeFn that uses a SubsumesFn to filter-out subsumed Positions from a State.
 
void operator() (State *state, std::size_t query_length)
 Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same State.
 

Private Attributes

SubsumesFn subsumes
 Determines whether one Position subsumes another given the maximum edit distance to consider.
 

Detailed Description

Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same State.

Definition at line 20 of file unsubsume.h.

Constructor & Destructor Documentation

◆ UnsubsumeFn()

liblevenshtein::UnsubsumeFn::UnsubsumeFn ( SubsumesFn subsumes)

Constructs a new UnsubsumeFn that uses a SubsumesFn to filter-out subsumed Positions from a State.

Parameters
subsumesDetermines whether one Position subsumes another given the maximum edit distance to consider.

Definition at line 8 of file unsubsume.cpp.

8: subsumes(std::move(subsumes)) {}
SubsumesFn subsumes
Determines whether one Position subsumes another given the maximum edit distance to consider.
Definition unsubsume.h:46

Member Function Documentation

◆ operator()()

void liblevenshtein::UnsubsumeFn::operator() ( State * state,
std::size_t query_length )

Removes (unsubsumes) all Positions from a State that are subsumed by another Position within the same State.

Parameters
stateState whose subsumed Positions are to be removed.
query_lengthMaximum edit distance to consider when matching spelling candidates.

Definition at line 10 of file unsubsume.cpp.

10 {
11 StateIterator outer_iter = state->begin();
12 StateIterator iter_end = state->end();
13 while (outer_iter != iter_end) {
14 Position *outer = *outer_iter;
15 std::size_t outer_errors = outer->num_errors();
16
17 StateIterator inner_iter(state, outer, &outer_iter);
18 ++inner_iter;
19
20 while (inner_iter != iter_end) {
21 Position *inner = *inner_iter;
22 if (outer_errors < inner->num_errors()) {
23 break;
24 }
25 ++inner_iter;
26 }
27
28 while (inner_iter != iter_end) {
29 Position *inner = *inner_iter;
30 if (subsumes(outer, inner, query_length)) {
31 inner_iter.remove();
32 }
33 ++inner_iter;
34 }
35
36 ++outer_iter;
37 }
38}
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25

References liblevenshtein::State::begin(), liblevenshtein::State::end(), liblevenshtein::Position::num_errors(), query(), and subsumes.

Here is the call graph for this function:

Member Data Documentation

◆ subsumes

SubsumesFn liblevenshtein::UnsubsumeFn::subsumes
private

Determines whether one Position subsumes another given the maximum edit distance to consider.

Definition at line 46 of file unsubsume.h.

Referenced by operator()().


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