Sha256: 22c7c871fd7b8132448aadebced768b067177ba2633f94a294841a0b18c0a4e7

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

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

module PragmaticSegmenter
  module Languages
    module Common
      # This class searches for ellipses within a string and
      # replaces the periods.

      # http://www.dailywritingtips.com/in-search-of-a-4-dot-ellipsis/
      # http://www.thepunctuationguide.com/ellipses.html

      module EllipsisRules
        # Rubular: http://rubular.com/r/i60hCK81fz
        ThreeConsecutiveRule = Rule.new(/\.\.\.(?=\s+[A-Z])/, '☏.')

        # Rubular: http://rubular.com/r/Hdqpd90owl
        FourConsecutiveRule = Rule.new(/(?<=\S)\.{3}(?=\.\s[A-Z])/, 'ƪ')

        # Rubular: http://rubular.com/r/YBG1dIHTRu
        ThreeSpaceRule = Rule.new(/(\s\.){3}\s/, '♟')

        # Rubular: http://rubular.com/r/2VvZ8wRbd8
        FourSpaceRule = Rule.new(/(?<=[a-z])(\.\s){3}\.(\z|$|\n)/, '♝')

        OtherThreePeriodRule = Rule.new(/\.\.\./, 'ƪ')

        All = [
          ThreeSpaceRule,
          FourSpaceRule,
          FourConsecutiveRule,
          ThreeConsecutiveRule,
          OtherThreePeriodRule
        ]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pragmatic_segmenter-0.3.24 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.23 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.22 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.21 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.20 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.19 lib/pragmatic_segmenter/languages/common/ellipsis.rb
pragmatic_segmenter-0.3.18 lib/pragmatic_segmenter/languages/common/ellipsis.rb