Class: FuzzyMatch::Score
- Inherits:
-
Object
- Object
- FuzzyMatch::Score
- Includes:
- Comparable
- Defined in:
- lib/fuzzy_match/score.rb,
lib/fuzzy_match/score/amatch.rb,
lib/fuzzy_match/score/pure_ruby.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#str1 ⇒ Object
readonly
Returns the value of attribute str1.
-
#str2 ⇒ Object
readonly
Returns the value of attribute str2.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(str1, str2) ⇒ Score
constructor
A new instance of Score.
- #inspect ⇒ Object
Constructor Details
#initialize(str1, str2) ⇒ Score
Returns a new instance of Score.
11 12 13 14 |
# File 'lib/fuzzy_match/score.rb', line 11 def initialize(str1, str2) @str1 = str1.downcase @str2 = str2.downcase end |
Instance Attribute Details
#str1 ⇒ Object (readonly)
Returns the value of attribute str1.
8 9 10 |
# File 'lib/fuzzy_match/score.rb', line 8 def str1 @str1 end |
#str2 ⇒ Object (readonly)
Returns the value of attribute str2.
9 10 11 |
# File 'lib/fuzzy_match/score.rb', line 9 def str2 @str2 end |
Instance Method Details
#<=>(other) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/fuzzy_match/score.rb', line 20 def <=>(other) a = dices_coefficient_similar b = other.dices_coefficient_similar if a.nan? or b.nan? or (by_dices_coefficient = (a <=> b)) == 0 levenshtein_similar <=> other.levenshtein_similar else by_dices_coefficient end end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/fuzzy_match/score.rb', line 16 def inspect %{(dice=#{"%0.5f" % dices_coefficient_similar},lev=#{"%0.5f" % levenshtein_similar})} end |