Module: Amatch::StringMethods
- Included in:
- String
- Defined in:
- ext/amatch_ext.c
Instance Method Summary collapse
-
#levenshtein_similar(strings) ⇒ Object
XXX If called on a String, this string is used as a Amatch::DamerauLevenshtein#pattern to match against
strings. -
#hamming_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Hamming#pattern to match against
strings. -
#jaro_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Jaro#pattern to match against
strings. -
#jarowinkler_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::JaroWinkler#pattern to match against
strings. -
#levenshtein_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Levenshtein#pattern to match against
strings. -
#longest_subsequence_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::LongestSubsequence#pattern to match against
strings. -
#longest_substring_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::LongestSubstring#pattern to match against
strings. -
#pair_distance_similar(strings, regexp = nil) ⇒ Object
If called on a String, this string is used as a Amatch::PairDistance#pattern to match against
stringsusing /s+/ as the tokenizing regular expression.
Instance Method Details
#levenshtein_similar(strings) ⇒ Object
XXX If called on a String, this string is used as a Amatch::DamerauLevenshtein#pattern to match against strings. It returns a DamerauLevenshtein 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 Float or an Array of Floats respectively.
1074 1075 1076 1077 1078 |
# File 'ext/amatch_ext.c', line 1074
static VALUE rb_str_damerau_levenshtein_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_DamerauLevenshtein_new(rb_cDamerauLevenshtein, self);
return rb_DamerauLevenshtein_similar(amatch, strings);
}
|
#hamming_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Hamming#pattern to match against strings. It returns a Hamming 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 Float or an Array of Floats respectively.
1445 1446 1447 1448 1449 |
# File 'ext/amatch_ext.c', line 1445
static VALUE rb_str_hamming_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_Hamming_new(rb_cHamming, self);
return rb_Hamming_similar(amatch, strings);
}
|
#jaro_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Jaro#pattern to match against strings. It returns a Jaro 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 Float or an Array of Floats respectively.
1670 1671 1672 1673 1674 |
# File 'ext/amatch_ext.c', line 1670
static VALUE rb_str_jaro_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_Jaro_new(rb_cJaro, self);
return rb_Jaro_match(amatch, strings);
}
|
#jarowinkler_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::JaroWinkler#pattern to match against strings. It returns a Jaro-Winkler 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 are either a Float or an Array of Floats respectively.
1768 1769 1770 1771 1772 |
# File 'ext/amatch_ext.c', line 1768
static VALUE rb_str_jarowinkler_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_JaroWinkler_new(rb_cJaro, self);
return rb_JaroWinkler_match(amatch, strings);
}
|
#levenshtein_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::Levenshtein#pattern to match against strings. It returns a Levenshtein 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 Float or an Array of Floats respectively.
982 983 984 985 986 |
# File 'ext/amatch_ext.c', line 982
static VALUE rb_str_levenshtein_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_Levenshtein_new(rb_cLevenshtein, self);
return rb_Levenshtein_similar(amatch, strings);
}
|
#longest_subsequence_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::LongestSubsequence#pattern to match against strings. It returns a longest subsequence 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 Float or an Array of Floats respectively.
1520 1521 1522 1523 1524 |
# File 'ext/amatch_ext.c', line 1520
static VALUE rb_str_longest_subsequence_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_LongestSubsequence_new(rb_cLongestSubsequence, self);
return rb_LongestSubsequence_similar(amatch, strings);
}
|
#longest_substring_similar(strings) ⇒ Object
If called on a String, this string is used as a Amatch::LongestSubstring#pattern to match against strings. It returns 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 Float or an Array of Floats respectively.
1597 1598 1599 1600 1601 |
# File 'ext/amatch_ext.c', line 1597
static VALUE rb_str_longest_substring_similar(VALUE self, VALUE strings)
{
VALUE amatch = rb_LongestSubstring_new(rb_cLongestSubstring, self);
return rb_LongestSubstring_similar(amatch, strings);
}
|
#pair_distance_similar(strings, regexp = nil) ⇒ Object
If called on a String, this string is used as a Amatch::PairDistance#pattern to match against strings using /s+/ as the tokenizing regular expression. It returns a pair 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 Float or an Array of Floats respectively.
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
# File 'ext/amatch_ext.c', line 1362
static VALUE rb_str_pair_distance_similar(int argc, VALUE *argv, VALUE self)
{
VALUE amatch, string, regexp = Qnil;
rb_scan_args(argc, argv, "11", &string, ®exp);
amatch = rb_PairDistance_new(rb_cPairDistance, self);
if (NIL_P(regexp)) {
return rb_PairDistance_match(1, &string, amatch);
} else {
VALUE *args = alloca(2);
args[0] = string;
args[1] = regexp;
return rb_PairDistance_match(2, args, amatch);
}
}
|