Class: Iriq::Evidence::Record
- Inherits:
-
Object
- Object
- Iriq::Evidence::Record
- 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
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#subject_kind ⇒ Object
readonly
Returns the value of attribute subject_kind.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(subject_kind:, subject:, source:, payload:, weight: nil, notes: []) ⇒ Record
constructor
A new instance of Record.
- #to_h ⇒ Object
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
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
50 51 52 |
# File 'lib/iriq/evidence.rb', line 50 def notes @notes end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
50 51 52 |
# File 'lib/iriq/evidence.rb', line 50 def payload @payload end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
50 51 52 |
# File 'lib/iriq/evidence.rb', line 50 def source @source end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
50 51 52 |
# File 'lib/iriq/evidence.rb', line 50 def subject @subject end |
#subject_kind ⇒ Object (readonly)
Returns the value of attribute subject_kind.
50 51 52 |
# File 'lib/iriq/evidence.rb', line 50 def subject_kind @subject_kind end |
#weight ⇒ Object (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_h ⇒ Object
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 |