Class: Olyx::Guardrails::Text::MappedNormalization
- Inherits:
-
Object
- Object
- Olyx::Guardrails::Text::MappedNormalization
- Defined in:
- lib/olyx/guardrails/text/mapped_normalization.rb
Overview
Holds normalized detector text and translates matches to original spans.
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(source) ⇒ MappedNormalization
constructor
A new instance of MappedNormalization.
- #original_span(starting, ending) ⇒ Object
Constructor Details
#initialize(source) ⇒ MappedNormalization
Returns a new instance of MappedNormalization.
12 13 14 15 |
# File 'lib/olyx/guardrails/text/mapped_normalization.rb', line 12 def initialize(source) @source = source @text, @starts, @endings = MappedBuilder.call(source) end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
10 11 12 |
# File 'lib/olyx/guardrails/text/mapped_normalization.rb', line 10 def text @text end |
Instance Method Details
#changed? ⇒ Boolean
17 18 19 |
# File 'lib/olyx/guardrails/text/mapped_normalization.rb', line 17 def changed? @text != @source end |
#original_span(starting, ending) ⇒ Object
21 22 23 |
# File 'lib/olyx/guardrails/text/mapped_normalization.rb', line 21 def original_span(starting, ending) [@starts.fetch(starting), @endings.fetch(ending - 1)] end |