class Amatch::JaroWinkler

This class computes the Jaro-Winkler metric for two strings. The Jaro-Winkler metric computes the similarity between 0 (no match) and 1 (exact match) by looking for matching and transposed characters.

It is a variant of the Jaro metric, with additional weighting towards common prefixes.

Public Class Methods

new(pattern) click to toggle source

Creates a new Amatch::JaroWinkler instance from pattern.

static VALUE rb_JaroWinkler_initialize(VALUE self, VALUE pattern)
{
    GET_STRUCT(JaroWinkler)
    JaroWinkler_pattern_set(amatch, pattern);
    amatch->ignore_case = 1;
    amatch->scaling_factor = 0.1;
    return self;
}

Public Instance Methods

ignore_case → true/false

Returns whether case is ignored when computing matching characters.

ignore_case=(true/false)

Sets whether case is ignored when computing matching characters.

match(strings) → results click to toggle source

Uses this Amatch::Jaro instance to match Jaro#pattern against strings, that is compute the jaro metric with the strings. strings has to be either a String or an Array of Strings. The returned results is either a Float or an Array of Floats respectively.

static VALUE rb_JaroWinkler_match(VALUE self, VALUE strings)
{
    GET_STRUCT(JaroWinkler)
    return JaroWinkler_iterate_strings(amatch, strings, JaroWinkler_match);
}
Also aliased as: similar
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.

scaling_factor → weight

The scaling factor is how much weight to give common prefixes. Default is 0.1.

scaling_factor=(weight)

Sets the weight to give common prefixes.

Uses this Amatch::Jaro instance to match Jaro#pattern against strings, that is compute the jaro metric with the strings. strings has to be either a String or an Array of Strings. The returned results is either a Float or an Array of Floats respectively.

Alias for: match