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

EXCLAMATION_WORDS =
%w[!Xũ !Kung ǃʼOǃKung !Xuun !Kung-Ekoka ǃHu ǃKhung ǃKu ǃung ǃXo ǃXû ǃXung ǃXũ !Xun Yahoo! Y!J Yum!].freeze
REGEXP =
Regexp.new(EXCLAMATION_WORDS.map { |string| Regexp.escape(string) }.join('|'))

Class Method Summary collapse

Class Method Details

.apply_rules(text) ⇒ Object



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

def self.apply_rules(text)
  PragmaticSegmenter::PunctuationReplacer.new(
    matches_array: text.scan(REGEXP),
    text: text
  ).replace
end