class Amatch::LongestSubstring
The longest common substring is the longest substring, that is part of two strings. A substring is contiguous, while a subsequence need not to be. The longer the common substring is, the more similar the two strings will be.
The longest common substring between 'string' and 'string' is 'string' again, thus the longest common substring length is 6. The longest common substring between 'string' and 'storing' is 'ring', thus the longest common substring length is 4.
Public Class Methods
Creates a new Amatch::LongestSubstring
instance from pattern
.
static VALUE rb_LongestSubstring_initialize(VALUE self, VALUE pattern) { GET_STRUCT(General) General_pattern_set(amatch, pattern); return self; }
Public Instance Methods
Uses this Amatch::LongestSubstring
instance to match LongestSubstring#pattern
against strings
, that is compute the length of the longest common substring. 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_LongestSubstring_match(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, LongestSubstring_match); }
Returns the current pattern string of this Amatch::Sellers
instance.
Sets the current pattern string of this Amatch::Sellers
instance to pattern
.
Uses this Amatch::LongestSubstring
instance to match Amatch::LongestSubstring#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 respectively.
static VALUE rb_LongestSubstring_similar(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, LongestSubstring_similar); }