Module: PragmaticSegmenter::ExclamationWords

Defined in:
lib/pragmatic_segmenter/exclamation_words.rb

Overview

This class searches for exclamation points that are part of words and not ending punctuation and replaces them.

Constant Summary collapse

WORDS_WITH_EXCLAMATIONS =
['!Xũ', '!Kung', 'ǃʼOǃKung', '!Xuun', '!Kung-Ekoka', 'ǃHu', 'ǃKhung', 'ǃKu', 'ǃung', 'ǃXo', 'ǃXû', 'ǃXung', 'ǃXũ', '!Xun', 'Yahoo!', 'Y!J', 'Yum!']

Class Method Summary collapse

Class Method Details

.apply_rules(text) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/pragmatic_segmenter/exclamation_words.rb', line 10

def self.apply_rules(text)
  WORDS_WITH_EXCLAMATIONS.each do |exclamation|
    PragmaticSegmenter::PunctuationReplacer.new(
      matches_array: text.scan(/#{Regexp.escape(exclamation)}/),
      text: text
    ).replace
  end
end