class Amatch::DamerauLevenshtein

XXX The DamerauLevenshtein edit distance is defined as the minimal costs involved to transform one string into another by using three elementary operations: deletion, insertion and substitution of a character. To transform “water” into “wine”, for instance, you have to substitute “a” -> “i”: “witer”, “t” -> “n”: “winer” and delete “r”: “wine”. The edit distance between “water” and “wine” is 3, because you have to apply three operations. The edit distance between “wine” and “wine” is 0 of course: no operation is necessary for the transformation – they're already the same string. It's easy to see that more similar strings have smaller edit distances than strings that differ a lot.

Public Class Methods

new(pattern) click to toggle source
XXX
Creates a new Amatch::DamerauLevenshtein instance from <code>pattern</code>.
static VALUE rb_DamerauLevenshtein_initialize(VALUE self, VALUE pattern)
{
    GET_STRUCT(General)
    General_pattern_set(amatch, pattern);
    return self;
}

Public Instance Methods

match(strings) → results click to toggle source
XXX
Uses this Amatch::DamerauLevenshtein instance to match Amatch::DamerauLevenshtein#pattern
against <code>strings</code>. It returns the number operations, the Sellers
<code>strings</code> has to be either a String or an Array of
The returned <code>results</code> is either a Float or an Array of
Floats respectively.
static VALUE rb_DamerauLevenshtein_match(VALUE self, VALUE strings)
{
    GET_STRUCT(General)
    return General_iterate_strings(amatch, strings, DamerauLevenshtein_match);
}
pattern → pattern string

Returns the current pattern string of this Amatch::Sellers instance.

pattern=(pattern)

Sets the current pattern string of this Amatch::Sellers instance to pattern.

similar(strings) → results click to toggle source
XXX
Uses this Amatch::DamerauLevenshtein instance to match Amatch::DamerauLevenshtein#pattern
against <code>strings</code>, and compute a DamerauLevenshtein distance metric
number between 0.0 for very unsimilar strings and 1.0 for an exact match.
<code>strings</code> has to be either a String or an Array of Strings. The
returned <code>results</code> is either a Fixnum or an Array of Fixnums
static VALUE rb_DamerauLevenshtein_similar(VALUE self, VALUE strings)
{
    GET_STRUCT(General)
    return General_iterate_strings(amatch, strings, DamerauLevenshtein_similar);
}