class Amatch::LongestSubsequence
This class computes the length of the longest subsequence common to two strings. A subsequence doesn't have to be contiguous. The longer the common subsequence is, the more similar the two strings will be.
The longest common subsequence between “test” and “test” is of length 4, because “test” itself is this subsequence. The longest common subsequence between “test” and “east” is “e”, “s”, “t” and the length of the sequence is 3.
Public Class Methods
Creates a new Amatch::LongestSubsequence instance from
pattern
.
static VALUE rb_LongestSubsequence_initialize(VALUE self, VALUE pattern) { GET_STRUCT(General) General_pattern_set(amatch, pattern); return self; }
Public Instance Methods
Uses this Amatch::LongestSubsequence
instance to match #pattern against
strings
, that is compute the length of the longest common
subsequence. strings
has to be either a String or an Array of Strings. The returned
results
is either a Fixnum or an Array of Fixnums
respectively.
static VALUE rb_LongestSubsequence_match(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, LongestSubsequence_match); }
Returns the current pattern string of this instance.
Sets the current pattern string of this instance to pattern
.
Uses this Amatch::LongestSubsequence
instance to match #pattern against
strings
, and compute a longest substring 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
is either a
Fixnum or an Array of Fixnums
static VALUE rb_LongestSubsequence_similar(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, LongestSubsequence_similar); }