Class: Ibex::TableArtifact::Executor
- Inherits:
-
Object
- Object
- Ibex::TableArtifact::Executor
- Defined in:
- lib/ibex/table_artifact/executor.rb
Overview
Recognition-only driver over internal token ids; it never loads wrapper code.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(document) ⇒ Executor
constructor
A new instance of Executor.
- #recognize(token_ids, entry: nil, max_steps: 1_000_000) ⇒ Object
Constructor Details
#initialize(document) ⇒ Executor
Returns a new instance of Executor.
31 32 33 34 35 36 37 38 39 |
# File 'lib/ibex/table_artifact/executor.rb', line 31 def initialize(document) @payload = document.is_a?(Document) ? document.payload : Document.new(document).payload @tables = @payload.fetch("tables") #: Hash[String, ValidationSupport::json_value] @productions = @payload.fetch("productions") #: Array[Hash[String, ValidationSupport::json_value]] tokens = @payload.fetch("tokens") #: Array[Hash[String, ValidationSupport::json_value]] @terminal_ids = tokens.map do |token| token.fetch("id") #: Integer end end |
Instance Method Details
#recognize(token_ids, entry: nil, max_steps: 1_000_000) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/ibex/table_artifact/executor.rb', line 42 def recognize(token_ids, entry: nil, max_steps: 1_000_000) raise ArgumentError, "max_steps must be positive" unless max_steps.is_a?(Integer) && max_steps.positive? input = validate_input(token_ids) input << 0 unless input.last&.zero? stack = [entry_state(entry)] execute(input, stack, max_steps) end |