Class: Amatch::LongestSubstring
- Inherits:
-
Object
- Object
- Amatch::LongestSubstring
- Defined in:
- ext/amatch_ext.c,
ext/amatch_ext.c
Overview
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.
Instance Method Summary collapse
- #initialize ⇒ Object constructor
- #match ⇒ Object
-
#pattern ⇒ Object
call-seq: pattern -> pattern string.
-
#pattern= ⇒ Object
call-seq: pattern=(pattern).
-
#similar(strings) ⇒ Object
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.
Constructor Details
#initialize ⇒ Object
Instance Method Details
#match ⇒ Object
#pattern ⇒ Object
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::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.
1358 1359 1360 1361 1362 |
# File 'ext/amatch_ext.c', line 1358
static VALUE rb_LongestSubstring_similar(VALUE self, VALUE strings)
{
GET_STRUCT(General)
return General_iterate_strings(amatch, strings, LongestSubstring_similar);
}
|