Class Amatch::Sellers
In: ext/amatch.c
Parent: Object

The Sellers edit distance is very similar to the Levenshtein edit distance. The difference is, that you can also specify different weights for every operation to prefer special operations over others. This extension of the Sellers edit distance is also known under the names: Needleman-Wunsch distance.

Methods

Public Class methods

Creates a new Amatch::Sellers instance from pattern, with all weights initially set to 1.0.

Public Instance methods

deletion → weight

Returns the weight of the deletion operation, that is used to compute the Sellers distance.

deletion=(weight)

Sets the weight of the deletion operation, that is used to compute the Sellers distance, to weight. The weight should be a Float value >= 0.0.

insertion → weight

Returns the weight of the insertion operation, that is used to compute the Sellers distance.

insertion=(weight)

Sets the weight of the insertion operation, that is used to compute the Sellers distance, to weight. The weight should be a Float value >= 0.0.

Uses this Amatch::Sellers instance to match Sellers#pattern against strings, while taking into account the given weights. It returns the number of weighted character operations, the Sellers distance. strings has to be either a String or an Array of Strings. The returned results are either a Float or an Array of Floats respectively.

pattern → pattern string

Returns the current pattern string of this instance.

pattern=(pattern)

Sets the current pattern string of this instance to pattern.

Resets all weights (substitution, deletion, and insertion) to 1.0.

searches Sellers#pattern in strings and returns the edit distance (the sum of weighted character operations) as a Float value, by greedy trimming prefixes or postfixes of the match. strings has to be either a String or an Array of Strings. The returned results are either a Float or an Array of Floats respectively.

Uses this Amatch::Sellers instance to match Amatch::Sellers#pattern against strings (taking into account the given weights), and compute a Sellers distance metric number between 0.0 for very unsimilar strings and 1.0 for an exact match. strings has to be either a String or an Array of Strings. The returned results are either a Fixnum or an Array of Fixnums respectively.

substitution → weight

Returns the weight of the substitution operation, that is used to compute the Sellers distance.

substitution=(weight)

Sets the weight of the substitution operation, that is used to compute the Sellers distance, to weight. The weight should be a Float value >= 0.0.

[Validate]