Class: Kohagi::Result
- Inherits:
-
Struct
- Object
- Struct
- Kohagi::Result
- Defined in:
- lib/kohagi/result.rb
Overview
One output record: the echoed id and its vector, plus the optional
--report-tokens fields. id is whatever JSON value was sent, unchanged.
Instance Attribute Summary collapse
-
#embedding ⇒ Object
Returns the value of attribute embedding.
-
#id ⇒ Object
Returns the value of attribute id.
-
#n_tokens ⇒ Object
Returns the value of attribute n_tokens.
-
#truncated ⇒ Object
Returns the value of attribute truncated.
Class Method Summary collapse
-
.from_json(line) ⇒ Object
Parse one JSONL line from kohagi's stdout.
Instance Method Summary collapse
-
#truncated? ⇒ Boolean
True only when kohagi reported this text as truncated (needs
report_tokens: true); nil/false otherwise.
Instance Attribute Details
#embedding ⇒ Object
Returns the value of attribute embedding
8 9 10 |
# File 'lib/kohagi/result.rb', line 8 def @embedding end |
#id ⇒ Object
Returns the value of attribute id
8 9 10 |
# File 'lib/kohagi/result.rb', line 8 def id @id end |
#n_tokens ⇒ Object
Returns the value of attribute n_tokens
8 9 10 |
# File 'lib/kohagi/result.rb', line 8 def n_tokens @n_tokens end |
#truncated ⇒ Object
Returns the value of attribute truncated
8 9 10 |
# File 'lib/kohagi/result.rb', line 8 def truncated @truncated end |
Class Method Details
.from_json(line) ⇒ Object
Parse one JSONL line from kohagi's stdout.
16 17 18 19 20 21 22 23 24 |
# File 'lib/kohagi/result.rb', line 16 def self.from_json(line) row = JSON.parse(line) new( id: row["id"], embedding: row["embedding"], n_tokens: row["n_tokens"], truncated: row["truncated"] ) end |
Instance Method Details
#truncated? ⇒ Boolean
True only when kohagi reported this text as truncated (needs
report_tokens: true); nil/false otherwise.
11 12 13 |
# File 'lib/kohagi/result.rb', line 11 def truncated? truncated == true end |