Module: Iriq::Evidence
- Defined in:
- lib/iriq/evidence.rb
Overview
Evidence is the structured substrate for explanation. Each Record captures one fact about the system's reasoning: "this segment classified as :integer because the Integer recognizer fired with specificity TYPED", "the IPv4 type collapses to ip by policy", "Position P is mostly variable because of corpus stats".
Trace and Explanation are views over a list of Evidence records; the structured form is what programmatic consumers (test assertions, PR-diff annotators, downstream tooling) should build on. Human note strings emitted by Trace are derived from Evidence payloads, so adding a new note kind starts with adding a new Evidence shape.
Two axes:
subject_kind
Defined Under Namespace
Classes: Record
Constant Summary collapse
- SUBJECT_KINDS =
i[segment position cluster].freeze
- SOURCES =
i[lexical recognizer corpus neighbor policy].freeze
Class Method Summary collapse
- .cluster(key:, source:, payload:, weight: nil, notes: []) ⇒ Object
- .position(position:, source:, payload:, weight: nil, notes: []) ⇒ Object
-
.segment(index:, value:, source:, payload:, weight: nil, notes: []) ⇒ Object
Factories so call sites don't have to repeat subject_kind:.
Class Method Details
.cluster(key:, source:, payload:, weight: nil, notes: []) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/iriq/evidence.rb', line 106 def cluster(key:, source:, payload:, weight: nil, notes: []) Record.new( subject_kind: :cluster, subject: key, source: source, payload: payload, weight: weight, notes: notes, ) end |
.position(position:, source:, payload:, weight: nil, notes: []) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/iriq/evidence.rb', line 98 def position(position:, source:, payload:, weight: nil, notes: []) Record.new( subject_kind: :position, subject: position, source: source, payload: payload, weight: weight, notes: notes, ) end |
.segment(index:, value:, source:, payload:, weight: nil, notes: []) ⇒ Object
Factories so call sites don't have to repeat subject_kind:.
90 91 92 93 94 95 96 |
# File 'lib/iriq/evidence.rb', line 90 def segment(index:, value:, source:, payload:, weight: nil, notes: []) Record.new( subject_kind: :segment, subject: { index: index, value: value }, source: source, payload: payload, weight: weight, notes: notes, ) end |