Sha256: 12b10a9c7c15b572026350ba6f052ffea8a0ff23f6981294593f57b5c7bbe33d

Contents?: true

Size: 708 Bytes

Versions: 7

Compression:

Stored size: 708 Bytes

Contents

# -*- encoding : utf-8 -*-
# frozen_string_literal: true

require 'pragmatic_segmenter/punctuation_replacer'

module PragmaticSegmenter
  # This class searches for exclamation points that
  # are part of words and not ending punctuation and replaces them.
  module ExclamationWords
    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('|'))

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pragmatic_segmenter-0.3.24 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.23 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.22 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.21 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.20 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.19 lib/pragmatic_segmenter/exclamation_words.rb
pragmatic_segmenter-0.3.18 lib/pragmatic_segmenter/exclamation_words.rb