Class: Iriq::Evidence::Record

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

Overview

A single Evidence fact.

subject_kind — :segment | :position | :cluster
subject      — kind-specific identity:
                 :segment  → { index:, value: }
                 :position → Iriq::Position
                 :cluster  → cluster key (string)
source       — :lexical | :recognizer | :corpus | :neighbor | :policy
payload      — source-and-kind-specific structured data
weight       — optional float in [0,1] — contribution to the
               ultimate decision. Set when scoring is meaningful;
               nil otherwise.
notes        — optional human-readable strings. Trace renders
               these directly; programmatic consumers can ignore.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject_kind:, subject:, source:, payload:, weight: nil, notes: []) ⇒ Record

Returns a new instance of Record.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/iriq/evidence.rb', line 52

def initialize(subject_kind:, subject:, source:, payload:, weight: nil, notes: [])
  unless SUBJECT_KINDS.include?(subject_kind)
    raise ArgumentError, "subject_kind must be one of #{SUBJECT_KINDS.inspect}"
  end
  unless SOURCES.include?(source)
    raise ArgumentError, "source must be one of #{SOURCES.inspect}"
  end

  @subject_kind = subject_kind
  @subject      = subject
  @source       = source
  @payload      = payload || {}
  @weight       = weight
  @notes        = notes || []
end

Instance Attribute Details

#notesObject (readonly)

Returns the value of attribute notes.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def notes
  @notes
end

#payloadObject (readonly)

Returns the value of attribute payload.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def payload
  @payload
end

#sourceObject (readonly)

Returns the value of attribute source.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def source
  @source
end

#subjectObject (readonly)

Returns the value of attribute subject.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def subject
  @subject
end

#subject_kindObject (readonly)

Returns the value of attribute subject_kind.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def subject_kind
  @subject_kind
end

#weightObject (readonly)

Returns the value of attribute weight.



50
51
52
# File 'lib/iriq/evidence.rb', line 50

def weight
  @weight
end

Instance Method Details

#to_hObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/iriq/evidence.rb', line 68

def to_h
  {
    subject_kind: @subject_kind,
    subject:      subject_serialized,
    source:       @source,
    payload:      @payload,
    weight:       @weight,
    notes:        @notes,
  }.compact
end