liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
|
Computes the standard Levenshtein distance extended with the elementary operation of transposition. More...
#include <transposition_distance.h>
Public Member Functions | |
auto | between (std::string v, std::string w) -> std::size_t override |
Measures the edit distance between two terms. | |
auto | operator() (const std::string &v, const std::string &w) -> std::size_t |
Measures the edit distance between two terms. | |
Protected Member Functions | |
auto | get (const SymmetricPair &key, std::size_t &distance) -> bool |
Collects the memoized distance between the pair of terms represented by the SymmetricPair if the distance has been previously determined. | |
auto | set (const SymmetricPair &key, const std::size_t &distance) -> std::size_t |
Memoizes the distance between the SymmetricPair of terms for future reference. | |
Static Protected Member Functions | |
static auto | f (const std::string &u, std::size_t t) -> std::string |
Returns the suffix of \(u\) from position \(t\). | |
Private Attributes | |
std::unordered_map< SymmetricPair, std::size_t > | memo |
Memoized distances between pairs of terms. | |
std::shared_mutex | mutex |
Coordinates memoization among threads. | |
Computes the standard Levenshtein distance extended with the elementary operation of transposition.
This is most useful for correcting typographic errors.
Definition at line 15 of file transposition_distance.h.
|
overridevirtual |
Measures the edit distance between two terms.
v | First term to compare. |
w | Second term to compare. |
Implements liblevenshtein::distance::Distance.
Definition at line 6 of file transposition_distance.cpp.
References liblevenshtein::distance(), and query().
|
staticprotectedinherited |
Returns the suffix of \(u\) from position \(t\).
If \(t \ge \left|u\right|\), then the empty string is returned.
u | Term whose suffix is to be returned. |
t | Beginning position in u for the substring. |
u
beginning at position t
if \(t <
\left|u\right|\), or the empty string otherwise. Definition at line 26 of file memoized_distance.cpp.
References query().
|
protectedinherited |
Collects the memoized distance between the pair of terms represented by the SymmetricPair if the distance has been previously determined.
Otherwise, the distance is not collected and false is returned.
key | SymmetricPair of terms whose distance may have been memoized. |
distance | Outgoing reference containing the memoized distance between the pair of terms, if the distance has been previously determined. |
Definition at line 9 of file memoized_distance.cpp.
References liblevenshtein::distance(), and query().
|
inherited |
Measures the edit distance between two terms.
This is equivalent to calling between(v, w)
.
v | First term to compare. |
w | Second term to compare. |
Definition at line 5 of file distance.cpp.
References query().
|
protectedinherited |
Memoizes the distance between the SymmetricPair of terms for future reference.
key | SymmetricPair of terms whose distance is to be memoized. |
distance | Distance between the SymmetricPair of terms to memoize. |
Definition at line 19 of file memoized_distance.cpp.
References liblevenshtein::distance(), and query().
|
privateinherited |
Memoized distances between pairs of terms.
Definition at line 57 of file memoized_distance.h.
|
mutableprivateinherited |
Coordinates memoization among threads.
Definition at line 60 of file memoized_distance.h.