Class: Phronomy::Testing::Eval::Scorer::ExactMatch
- Defined in:
- lib/phronomy/testing/eval/scorer/exact_match.rb
Instance Method Summary collapse
-
#initialize(case_sensitive: true) ⇒ ExactMatch
constructor
A new instance of ExactMatch.
- #score(actual:, expected:, input: nil) ⇒ Object
Constructor Details
#initialize(case_sensitive: true) ⇒ ExactMatch
Returns a new instance of ExactMatch.
8 9 10 |
# File 'lib/phronomy/testing/eval/scorer/exact_match.rb', line 8 def initialize(case_sensitive: true) @case_sensitive = case_sensitive end |
Instance Method Details
#score(actual:, expected:, input: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/phronomy/testing/eval/scorer/exact_match.rb', line 12 def score(actual:, expected:, input: nil) actual_value = actual.to_s.strip expected_value = expected.to_s.strip unless @case_sensitive actual_value = actual_value.downcase expected_value = expected_value.downcase end (actual_value == expected_value) ? 1.0 : 0.0 end |