Class: Iriq::RecognizerProposal

Inherits:
Object
  • Object
show all
Defined in:
lib/iriq/recognizer_proposal.rb

Overview

A suggestion that a new Recognizer should be added to the system.

Emitted by Corpus#propose_recognizers. NOT automatically activated —proposals carry enough evidence for a human to judge whether to add the Recognizer to the built-in set (or, later, to register it dynamically via a public Recognizer registry).

prefix             — the detected shape signature (e.g. "ghp_")
suggested_type     — Symbol name we'd register the Recognizer under
                     if accepted (e.g. :ghp)
positions          — every Position where the proposal matched
hosts              — distinct hosts the proposal was seen at; a high
                     count is strong evidence the pattern isn't
                     host-local
coverage           — fraction of sampled observations at affected
                     Positions matching the proposal pattern
observation_count  — total matching observations across positions
sample_values      — up to 5 example matches, for the human reviewer
strategy           — the ProposalStrategy that emitted this record

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix:, suggested_type:, positions:, hosts:, coverage:, observation_count:, sample_values:, strategy:, confidence: nil) ⇒ RecognizerProposal

Returns a new instance of RecognizerProposal.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/iriq/recognizer_proposal.rb', line 28

def initialize(prefix:, suggested_type:, positions:, hosts:,
               coverage:, observation_count:, sample_values:,
               strategy:, confidence: nil)
  @prefix            = prefix
  @suggested_type    = suggested_type
  @positions         = positions.freeze
  @hosts             = hosts.is_a?(Set) ? hosts.dup.freeze : Set.new(hosts).freeze
  @coverage          = coverage
  @observation_count = observation_count
  @sample_values     = sample_values.freeze
  @strategy          = strategy
  @confidence        = confidence.nil? ? compute_confidence : confidence
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def confidence
  @confidence
end

#coverageObject (readonly)

Returns the value of attribute coverage.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def coverage
  @coverage
end

#hostsObject (readonly)

Returns the value of attribute hosts.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def hosts
  @hosts
end

#observation_countObject (readonly)

Returns the value of attribute observation_count.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def observation_count
  @observation_count
end

#positionsObject (readonly)

Returns the value of attribute positions.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def positions
  @positions
end

#prefixObject (readonly)

Returns the value of attribute prefix.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def prefix
  @prefix
end

#sample_valuesObject (readonly)

Returns the value of attribute sample_values.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def sample_values
  @sample_values
end

#strategyObject (readonly)

Returns the value of attribute strategy.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def strategy
  @strategy
end

#suggested_typeObject (readonly)

Returns the value of attribute suggested_type.



24
25
26
# File 'lib/iriq/recognizer_proposal.rb', line 24

def suggested_type
  @suggested_type
end

Instance Method Details

#to_hObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/iriq/recognizer_proposal.rb', line 42

def to_h
  {
    prefix:            @prefix,
    suggested_type:    @suggested_type,
    positions:         @positions.map(&:to_h),
    hosts:             @hosts.to_a.sort,
    coverage:          @coverage,
    confidence:        @confidence,
    observation_count: @observation_count,
    sample_values:     @sample_values,
    strategy:          @strategy,
  }
end