Class: EncodingEstimator::Detection

Inherits:
Object
  • Object
show all
Defined in:
lib/encoding_estimator/detection.rb

Overview

Class to represent the results of a detection process.

Instance Method Summary collapse

Constructor Details

#initialize(scores, conversions) ⇒ Detection

Initialize a new object from the evaluation scores and the conversions tested



11
12
13
14
# File 'lib/encoding_estimator/detection.rb', line 11

def initialize( scores, conversions )
  @scores      = scores
  @conversions = conversions
end

Instance Method Details

#resultEncodingEstimator::Conversion

Get the most probable conversion



19
20
21
# File 'lib/encoding_estimator/detection.rb', line 19

def result
  @result ||= calculate_result
end

#resultsArray<Hash>

Get all conversions and their scores



34
35
36
# File 'lib/encoding_estimator/detection.rb', line 34

def results
  @results ||= @conversions.map { |c| { conversion: c, score: @scores[ c.key ] } }
end

#scoreFloat

Get the score of the most probable conversion (-> the highest score)



26
27
28
# File 'lib/encoding_estimator/detection.rb', line 26

def score
  @scores[ result.key ]
end