Class: Gliner::Runners::ClassificationRunner
- Inherits:
-
Object
- Object
- Gliner::Runners::ClassificationRunner
- Includes:
- Inspectable
- Defined in:
- lib/gliner/runners/classification_runner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](text, **options) ⇒ Object (also: #call)
-
#initialize(model, tasks_config) ⇒ ClassificationRunner
constructor
A new instance of ClassificationRunner.
Methods included from Inspectable
Constructor Details
#initialize(model, tasks_config) ⇒ ClassificationRunner
Returns a new instance of ClassificationRunner.
12 13 14 15 16 17 18 19 |
# File 'lib/gliner/runners/classification_runner.rb', line 12 def initialize(model, tasks_config) raise Error, 'tasks must be a Hash' unless tasks_config.is_a?(Hash) @tasks = tasks_config.to_h do |name, config| parsed = model.classification_task.parse_config(name: name, config: config) [name.to_s, PreparedTask.new(model.classification_task, parsed)] end end |
Class Method Details
Instance Method Details
#[](text, **options) ⇒ Object Also known as: call
21 22 23 |
# File 'lib/gliner/runners/classification_runner.rb', line 21 def [](text, **) @tasks.transform_values { |task| task.call(text, **) } end |