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::Amharic::AbbreviationReplacer, Languages::Arabic::AbbreviationReplacer, Languages::Armenian::AbbreviationReplacer, Languages::Bulgarian::AbbreviationReplacer, Languages::Burmese::AbbreviationReplacer, Languages::Chinese::AbbreviationReplacer, Languages::Common::AbbreviationReplacer, Languages::Danish::AbbreviationReplacer, Languages::Deutsch::AbbreviationReplacer, Languages::English::AbbreviationReplacer, Languages::French::AbbreviationReplacer, Languages::Greek::AbbreviationReplacer, Languages::Hindi::AbbreviationReplacer, Languages::Italian::AbbreviationReplacer, Languages::Japanese::AbbreviationReplacer, Languages::Kazakh::AbbreviationReplacer, Languages::Persian::AbbreviationReplacer, Languages::Polish::AbbreviationReplacer, Languages::Russian::AbbreviationReplacer, Languages::Spanish::AbbreviationReplacer, Languages::Urdu::AbbreviationReplacer
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.
12 13 14 15 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 12 def initialize(text:, language: ) @text = text.dup @language = language end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 11 def text @text end |
Instance Method Details
#replace ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pragmatic_segmenter/abbreviation_replacer.rb', line 17 def replace Rule.apply(@text, @language::PossessiveAbbreviationRule, @language::KommanditgesellschaftRule, @language::SingleLetterAbbreviationRules::All) @text = search_for_abbreviations_in_string(@text) @text = replace_multi_period_abbreviations(@text) Rule.apply(@text, @language::AmPmRules::All) replace_abbreviation_as_sentence_boundary(@text) end |