Class: Raif::Evals::EvalCase

Inherits:
Object
  • Object
show all
Defined in:
lib/raif/evals/eval_case.rb

Overview

One input row of a Dataset. Eval sets only ever receive these - the dataset block returns plain hashes and Raif builds the cases from them.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, input:, expected: nil) ⇒ EvalCase

Returns a new instance of EvalCase.



10
11
12
13
14
15
# File 'lib/raif/evals/eval_case.rb', line 10

def initialize(id:, input:, expected: nil)
  @id = id.to_s.freeze
  @input = input
  @expected = expected
  freeze
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



8
9
10
# File 'lib/raif/evals/eval_case.rb', line 8

def expected
  @expected
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/raif/evals/eval_case.rb', line 8

def id
  @id
end

#inputObject (readonly)

Returns the value of attribute input.



8
9
10
# File 'lib/raif/evals/eval_case.rb', line 8

def input
  @input
end

Instance Method Details

#[](key) ⇒ Object

Reading straight through to the input keeps the common case short: eval_case rather than eval_case.input.



19
20
21
# File 'lib/raif/evals/eval_case.rb', line 19

def [](key)
  input[key]
end

#to_hObject



23
24
25
# File 'lib/raif/evals/eval_case.rb', line 23

def to_h
  { id: id, input: input, expected: expected }.compact
end