Class: PragmaticSegmenter::PunctuationReplacer
- Inherits:
-
Object
- Object
- PragmaticSegmenter::PunctuationReplacer
- Includes:
- Rules
- Defined in:
- lib/pragmatic_segmenter/punctuation_replacer.rb
Overview
This class replaces punctuation that is typically a sentence boundary but in this case is not a sentence boundary.
Constant Summary collapse
- BETWEEN_SINGLE_QUOTES_REGEX =
Rubular: rubular.com/r/2YFrKWQUYi
/(?<=\s)'(?:[^']|'[a-zA-Z])*'/
Constants included from Rules
Rules::AbbreviationsWithMultiplePeriodsAndEmailRule, Rules::ExtraWhiteSpaceRule, Rules::GeoLocationRule, Rules::QuestionMarkInQuotationRule, Rules::SingleNewLineRule, Rules::SubSingleQuoteRule
Instance Attribute Summary collapse
-
#match_type ⇒ Object
readonly
Returns the value of attribute match_type.
-
#matches_array ⇒ Object
readonly
Returns the value of attribute matches_array.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text:, matches_array:, **args) ⇒ PunctuationReplacer
constructor
A new instance of PunctuationReplacer.
- #replace ⇒ Object
Constructor Details
#initialize(text:, matches_array:, **args) ⇒ PunctuationReplacer
Returns a new instance of PunctuationReplacer.
12 13 14 15 16 |
# File 'lib/pragmatic_segmenter/punctuation_replacer.rb', line 12 def initialize(text:, matches_array:, **args) @text = text @matches_array = matches_array @match_type = args[:match_type] end |
Instance Attribute Details
#match_type ⇒ Object (readonly)
Returns the value of attribute match_type.
11 12 13 |
# File 'lib/pragmatic_segmenter/punctuation_replacer.rb', line 11 def match_type @match_type end |
#matches_array ⇒ Object (readonly)
Returns the value of attribute matches_array.
11 12 13 |
# File 'lib/pragmatic_segmenter/punctuation_replacer.rb', line 11 def matches_array @matches_array end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/pragmatic_segmenter/punctuation_replacer.rb', line 11 def text @text end |
Instance Method Details
#replace ⇒ Object
18 19 20 |
# File 'lib/pragmatic_segmenter/punctuation_replacer.rb', line 18 def replace replace_punctuation(matches_array, text) end |