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

Represents a location within the Levenshtein automaton. More...

#include <position.h>

Collaboration diagram for liblevenshtein::Position:

Public Member Functions

 Position (std::size_t term_index, std::size_t num_errors, bool is_special=false)
 Constructs a new Position within the Levenshtein automaton.
 
 ~Position ()
 Frees any owned allocations.
 
void next (Position *next)
 Assigns the subsequent Position along the current path.
 
auto next () const -> Position *
 Returns the Position that follows this one along the current path.
 
auto term_index () const -> std::size_t
 Returns the current position in the dictionary term.
 
auto num_errors () const -> std::size_t
 Returns the accumulated number of errors at the term_index.
 
auto is_special () const -> bool
 Returns whether this is a special state of one of the extended algorithms.
 

Private Attributes

Position_next = nullptr
 The Position that follows this one along the current path.
 
std::size_t _term_index
 The current position within the dictionary term.
 
std::size_t _num_errors
 The accumulated number of errors between the spelling candidate and query term, at term_index of the spelling candidate.
 
bool _is_special
 Whether this is a special state of one of the extended algorithms.
 

Detailed Description

Represents a location within the Levenshtein automaton.

Definition at line 11 of file position.h.

Constructor & Destructor Documentation

◆ Position()

liblevenshtein::Position::Position ( std::size_t term_index,
std::size_t num_errors,
bool is_special = false )

Constructs a new Position within the Levenshtein automaton.

Parameters
term_indexCurrent location within the dictionary term.
num_errorsAccumulated number of errors at the term_index.
is_specialWhether this is a special position representing an extended state.

Definition at line 5 of file position.cpp.

9{}
std::size_t _term_index
The current position within the dictionary term.
Definition position.h:71
auto term_index() const -> std::size_t
Returns the current position in the dictionary term.
Definition position.cpp:23
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
bool _is_special
Whether this is a special state of one of the extended algorithms.
Definition position.h:78

◆ ~Position()

liblevenshtein::Position::~Position ( )

Frees any owned allocations.

Definition at line 11 of file position.cpp.

11 {
12 delete _next;
13}
Position * _next
The Position that follows this one along the current path.
Definition position.h:68

References _next.

Member Function Documentation

◆ is_special()

auto liblevenshtein::Position::is_special ( ) const -> bool

Returns whether this is a special state of one of the extended algorithms.

Returns
Whether this Position is special within one of the extensions.

Definition at line 31 of file position.cpp.

31 {
32 return _is_special;
33}

References _is_special.

◆ next() [1/2]

auto liblevenshtein::Position::next ( ) const -> Position *

Returns the Position that follows this one along the current path.

Returns
A pointer to the position that follows this one.

Definition at line 19 of file position.cpp.

19 {
20 return _next;
21}

References _next.

Referenced by next().

Here is the caller graph for this function:

◆ next() [2/2]

void liblevenshtein::Position::next ( Position * next)

Assigns the subsequent Position along the current path.

Parameters
nextThe Position following this one.

Definition at line 15 of file position.cpp.

15 {
16 _next = next;
17}
auto next() const -> Position *
Returns the Position that follows this one along the current path.
Definition position.cpp:19

References _next, and next().

Referenced by liblevenshtein::State::add(), liblevenshtein::StateIterator::advance(), liblevenshtein::State::find_middle(), liblevenshtein::State::head(), liblevenshtein::State::insert_after(), liblevenshtein::State::merge(), liblevenshtein::State::merge_sort(), liblevenshtein::StateIterator::remove(), and liblevenshtein::State::remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_errors()

auto liblevenshtein::Position::num_errors ( ) const -> std::size_t

Returns the accumulated number of errors at the term_index.

Returns
The accumulated number of errors.

Definition at line 27 of file position.cpp.

27 {
28 return _num_errors;
29}

References _num_errors.

Referenced by liblevenshtein::UnsubsumeFn::operator()().

Here is the caller graph for this function:

◆ term_index()

auto liblevenshtein::Position::term_index ( ) const -> std::size_t

Returns the current position in the dictionary term.

Returns
The current position in the dictionary term.

Definition at line 23 of file position.cpp.

23 {
24 return _term_index;
25}

References _term_index.

Referenced by liblevenshtein::merge< Algorithm::MERGE_AND_SPLIT >(), liblevenshtein::merge< Algorithm::STANDARD >(), liblevenshtein::merge< Algorithm::TRANSPOSITION >(), liblevenshtein::position_transition< Algorithm::MERGE_AND_SPLIT >(), and liblevenshtein::position_transition< Algorithm::TRANSPOSITION >().

Here is the caller graph for this function:

Member Data Documentation

◆ _is_special

bool liblevenshtein::Position::_is_special
private

Whether this is a special state of one of the extended algorithms.

Definition at line 78 of file position.h.

Referenced by is_special().

◆ _next

Position* liblevenshtein::Position::_next = nullptr
private

The Position that follows this one along the current path.

Definition at line 68 of file position.h.

Referenced by next(), next(), and ~Position().

◆ _num_errors

std::size_t liblevenshtein::Position::_num_errors
private

The accumulated number of errors between the spelling candidate and query term, at term_index of the spelling candidate.

Definition at line 75 of file position.h.

Referenced by num_errors().

◆ _term_index

std::size_t liblevenshtein::Position::_term_index
private

The current position within the dictionary term.

Definition at line 71 of file position.h.

Referenced by term_index().


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