Class: SimpleInlineTextAnnotation::Parser
- Inherits:
-
Object
- Object
- SimpleInlineTextAnnotation::Parser
- Defined in:
- lib/simple_inline_text_annotation/parser.rb
Constant Summary collapse
- ANNOTATION_PATTERN =
DENOTATION_PATTERN matches two consecutive pairs of square brackets. Example: [Annotated Text]
/(?<!\\)\[([^\[]+?)\]\[([^\]]+?)\]/
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 |
# File 'lib/simple_inline_text_annotation/parser.rb', line 12 def initialize(source) @source = source.dup.freeze @entity_type_collection = EntityTypeCollection.new(source) end |
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_inline_text_annotation/parser.rb', line 17 def parse @denotations = [] @relations = [] full_text = source_without_references process_annotations(full_text) SimpleInlineTextAnnotation.new( full_text, @denotations, @relations, @entity_type_collection ) end |