Class: Dendroid::Recognizer::Chart
- Inherits:
-
Object
- Object
- Dendroid::Recognizer::Chart
- Extended by:
- Forwardable
- Defined in:
- lib/dendroid/recognizer/chart.rb
Overview
Also called a parse table. It records the progress of the Earley recognizer whens its verifies the compliance of the input text to the language grammar rules. It essentially consists in an array of item sets. If n is the number of input tokens then the chart has n + 1 entry sets.
Instance Attribute Summary collapse
-
#failure_class ⇒ StandardError
The exception class in case of an error found by the recognizer.
-
#failure_reason ⇒ String
The error message.
-
#item_sets ⇒ Array<Recognizer::ItemSet>
readonly
The array of item sets.
-
#success ⇒ Boolean
writeonly
Indicates whether the recognizer successfully processed the whole input.
Instance Method Summary collapse
-
#append_new_set ⇒ Object
Add a new empty item set at the end of the array of item sets.
-
#initialize ⇒ Chart
constructor
Constructor Initialize the chart with one empty item set.
-
#seed_last_set(e_item) ⇒ Object
Add an EItem to the last item set.
-
#successful? ⇒ Boolean
Return true if the input text is valid according to the grammar.
Constructor Details
#initialize ⇒ Chart
Constructor Initialize the chart with one empty item set.
31 32 33 34 35 |
# File 'lib/dendroid/recognizer/chart.rb', line 31 def initialize @item_sets = [] @success = false append_new_set end |
Instance Attribute Details
#failure_class ⇒ StandardError
Returns The exception class in case of an error found by the recognizer.
22 23 24 |
# File 'lib/dendroid/recognizer/chart.rb', line 22 def failure_class @failure_class end |
#failure_reason ⇒ String
Returns The error message.
25 26 27 |
# File 'lib/dendroid/recognizer/chart.rb', line 25 def failure_reason @failure_reason end |
#item_sets ⇒ Array<Recognizer::ItemSet> (readonly)
Returns The array of item sets.
16 17 18 |
# File 'lib/dendroid/recognizer/chart.rb', line 16 def item_sets @item_sets end |
#success=(value) ⇒ Boolean (writeonly)
Returns Indicates whether the recognizer successfully processed the whole input.
19 20 21 |
# File 'lib/dendroid/recognizer/chart.rb', line 19 def success=(value) @success = value end |
Instance Method Details
#append_new_set ⇒ Object
Add a new empty item set at the end of the array of item sets
38 39 40 |
# File 'lib/dendroid/recognizer/chart.rb', line 38 def append_new_set item_sets << ItemSet.new end |
#seed_last_set(e_item) ⇒ Object
Add an EItem to the last item set
44 45 46 |
# File 'lib/dendroid/recognizer/chart.rb', line 44 def seed_last_set(e_item) item_sets.last.add_item(e_item) end |
#successful? ⇒ Boolean
Return true if the input text is valid according to the grammar.
50 51 52 |
# File 'lib/dendroid/recognizer/chart.rb', line 50 def successful? @success end |