Class: Amatch::LongestSubsequence

Inherits:
Object
  • Object
show all
Defined in:
ext/amatch_ext.c,
ext/amatch_ext.c

Overview

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.

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Method Details

#matchObject

#patternObject

call-seq: pattern -> pattern string

Returns the current pattern string of this instance.

#pattern=Object

call-seq: pattern=(pattern)

Sets the current pattern string of this instance to pattern.

#similar(strings) ⇒ Object

Uses this Amatch::LongestSubsequence instance to match Amatch::LongestSubsequence#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



1280
1281
1282
1283
1284
# File 'ext/amatch_ext.c', line 1280

static VALUE rb_LongestSubsequence_similar(VALUE self, VALUE strings)
{                                                                            
    GET_STRUCT(General)
    return General_iterate_strings(amatch, strings, LongestSubsequence_similar);
}