Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- ext/similar_text/similar_text.c
Instance Method Summary collapse
-
#similar(str2) ⇒ Object
Calculate the similarity between strings.
-
#similar_chars(str2) ⇒ Object
Calculate the similarity between strings.
Instance Method Details
#similar(str2) ⇒ Object
Calculate the similarity between strings.
“Hello, World!”.similar(“Hello, World!”) #=> 100.0
65 66 67 68 69 70 71 72 |
# File 'ext/similar_text/similar_text.c', line 65
static VALUE t_similar(VALUE str1, VALUE str2)
{
double percent;
similar_text(StringValueCStr(str1), StringValueCStr(str2), &percent);
return rb_float_new(percent);
}
|
#similar_chars(str2) ⇒ Object
Calculate the similarity between strings.
‘Hello WORLD!’.similar_chars ‘Hello, World!’ #=> 8
81 82 83 84 85 86 87 88 89 |
# File 'ext/similar_text/similar_text.c', line 81
static VALUE t_similar_chars(VALUE str1, VALUE str2)
{
double percent;
int sim;
sim = similar_text(StringValueCStr(str1), StringValueCStr(str2), &percent);
return rb_int_new(sim);
}
|