libmoost
moost::string Namespace Reference

Functions

template<class RandomAccessIterator >
int levenshtein (RandomAccessIterator first1, RandomAccessIterator last1, RandomAccessIterator first2, RandomAccessIterator last2, std::vector< std::vector< int > > &d)
 Calculates levenshtein distance between two iterator ranges. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.
template<class RandomAccessIterator >
int levenshtein (RandomAccessIterator first1, RandomAccessIterator last1, RandomAccessIterator first2, RandomAccessIterator last2)
 Calculates levenshtein distance between two iterator ranges. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.
int levenshtein (const std::string &first, const std::string &second, std::vector< std::vector< int > > &d)
 Calculates levenshtein distance between two containers of two strings. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.
int levenshtein (const std::string &first, const std::string &second)
 Calculates levenshtein distance between two containers of any type, such as strings. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.
template<class RandomAccessIterator >
int fast_levenshtein (RandomAccessIterator first1, RandomAccessIterator last1, RandomAccessIterator first2, RandomAccessIterator last2, int thresh=INT_MAX)
 Space and time efficient simple levenshtein distance between two iterator ranges.
int fast_levenshtein (const std::string &first, const std::string &second, int thresh=INT_MAX)
 Space and time efficient simple levenshtein distance between two iterator ranges.

Function Documentation

template<class RandomAccessIterator >
int moost::string::fast_levenshtein ( RandomAccessIterator  first1,
RandomAccessIterator  last1,
RandomAccessIterator  first2,
RandomAccessIterator  last2,
int  thresh = INT_MAX 
)

Space and time efficient simple levenshtein distance between two iterator ranges.

Precondition:
the first string must be no longer than the second
Parameters:
threshdon't bother computing if the distance is bound to be more than this The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

Note that this is a plain levenshtein distance and not the damereau version of moost::levenshtein() which treats transposition of adjacent characters as a special case.

Definition at line 136 of file levenshtein.hpp.

Here is the caller graph for this function:

int moost::string::fast_levenshtein ( const std::string &  first,
const std::string &  second,
int  thresh = INT_MAX 
)

Space and time efficient simple levenshtein distance between two iterator ranges.

Parameters:
threshdon't bother computing if the distance is bound to be more than this The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

Note that this is a plain levenshtein distance and not the damereau version of moost::levenshtein() which treats transposition of adjacent characters as a special case.

Definition at line 194 of file levenshtein.hpp.

Here is the call graph for this function:

template<class RandomAccessIterator >
int moost::string::levenshtein ( RandomAccessIterator  first1,
RandomAccessIterator  last1,
RandomAccessIterator  first2,
RandomAccessIterator  last2,
std::vector< std::vector< int > > &  d 
)

Calculates levenshtein distance between two iterator ranges. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

This is technically damerau-levenshtein, but too long a name for a function.

Definition at line 46 of file levenshtein.hpp.

Here is the caller graph for this function:

template<class RandomAccessIterator >
int moost::string::levenshtein ( RandomAccessIterator  first1,
RandomAccessIterator  last1,
RandomAccessIterator  first2,
RandomAccessIterator  last2 
)

Calculates levenshtein distance between two iterator ranges. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

Definition at line 91 of file levenshtein.hpp.

Here is the call graph for this function:

int moost::string::levenshtein ( const std::string &  first,
const std::string &  second,
std::vector< std::vector< int > > &  d 
)

Calculates levenshtein distance between two containers of two strings. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

Definition at line 106 of file levenshtein.hpp.

Here is the call graph for this function:

int moost::string::levenshtein ( const std::string &  first,
const std::string &  second 
)

Calculates levenshtein distance between two containers of any type, such as strings. The levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.

Definition at line 118 of file levenshtein.hpp.

Here is the call graph for this function: