Class: PragmaticSegmenter::AbbreviationReplacer
- Inherits:
-
Object
- Object
- PragmaticSegmenter::AbbreviationReplacer
- Defined in:
- lib/pragmatic_segmenter/abbreviation_replacer.rb
Overview
This class searches for periods within an abbreviation and replaces the periods.
Direct Known Subclasses
Languages::Arabic::AbbreviationReplacer, Languages::Deutsch::AbbreviationReplacer, Languages::Persian::AbbreviationReplacer, Languages::Russian::AbbreviationReplacer
Constant Summary collapse
- SENTENCE_STARTERS =
%w(A Being Did For He How However I In It Millions More She That The There They We What When Where Who Why)
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text:, language:) ⇒ AbbreviationReplacer
constructor
A new instance of AbbreviationReplacer.
- #replace ⇒ Object
Constructor Details
#initialize(text:, language:) ⇒ AbbreviationReplacer
Returns a new instance of AbbreviationReplacer.
11 12 13 14 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 11 def initialize(text:, language: ) @text = Text.new(text) @language = language end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
10 11 12 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 10 def text @text end |
Instance Method Details
#replace ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 16 def replace @text.apply(@language::PossessiveAbbreviationRule, @language::KommanditgesellschaftRule, @language::SingleLetterAbbreviationRules::All) @text = search_for_abbreviations_in_string(@text) @text = replace_multi_period_abbreviations(@text) @text.apply(@language::AmPmRules::All) replace_abbreviation_as_sentence_boundary(@text) end |