Class: RSpec::Covers::Tracer::NCC
- Inherits:
-
Object
- Object
- RSpec::Covers::Tracer::NCC
- Defined in:
- lib/rspec/covers/tracer/ncc.rb
Instance Method Summary collapse
Instance Method Details
#score(example:, candidates:) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec/covers/tracer/ncc.rb', line 11 def score(example:, candidates:, **) description_tokens = Tokenizer.call(example.full_description).to_set candidates.each_with_object({}) do |candidate, scores| candidate_tokens = Tokenizer.call(candidate.label).to_set overlap = description_tokens & candidate_tokens scores[candidate.label] = candidate_tokens.empty? ? 0.0 : overlap.length.to_f / candidate_tokens.length end end |