Class: Amatch::LongestSubsequence
- Inherits:
-
Object
- Object
- Amatch::LongestSubsequence
- 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
-
#new(pattern) ⇒ Object
constructor
Creates a new Amatch::LongestSubsequence instance from
pattern. - #match ⇒ Object
-
#pattern ⇒ Object
call-seq: pattern -> pattern string.
-
#pattern= ⇒ Object
call-seq: pattern=(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.
Constructor Details
#new(pattern) ⇒ Object
Creates a new Amatch::LongestSubsequence instance from pattern.
1470 1471 1472 1473 1474 1475 |
# File 'ext/amatch_ext.c', line 1470
static VALUE rb_LongestSubsequence_initialize(VALUE self, VALUE pattern)
{
GET_STRUCT(General)
General_pattern_set(amatch, pattern);
return self;
}
|
Instance Method Details
#match ⇒ Object
#pattern ⇒ Object
call-seq: pattern -> pattern string
Returns the current pattern string of this Amatch::Sellers instance.
#pattern= ⇒ Object
call-seq: pattern=(pattern)
Sets the current pattern string of this Amatch::Sellers 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
1504 1505 1506 1507 1508 |
# File 'ext/amatch_ext.c', line 1504
static VALUE rb_LongestSubsequence_similar(VALUE self, VALUE strings)
{
GET_STRUCT(General)
return General_iterate_strings(amatch, strings, LongestSubsequence_similar);
}
|