Sha256: 4c7ca8ace04db434ce632c648bce805e7c1d37a5c0bfcb0d43c2befd43ae09d0
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding : utf-8 -*- module PragmaticSegmenter # This class searches for numbers with periods within a string and # replaces the periods. class Number # Rubular: http://rubular.com/r/oNyxBOqbyy PeriodBeforeNumberRule = Rule.new(/\.(?=\d)/, '∯') # Rubular: http://rubular.com/r/EMk5MpiUzt NumberAfterPeriodBeforeLetterRule = Rule.new(/(?<=\d)\.(?=\S)/, '∯') # Rubular: http://rubular.com/r/rf4l1HjtjG NewLineNumberPeriodSpaceLetterRule = Rule.new(/(?<=\r\d)\.(?=(\s\S)|\))/, '∯') # Rubular: http://rubular.com/r/HPa4sdc6b9 StartLineNumberPeriodRule = Rule.new(/(?<=^\d)\.(?=(\s\S)|\))/, '∯') # Rubular: http://rubular.com/r/NuvWnKleFl StartLineTwoDigitNumberPeriodRule = Rule.new(/(?<=^\d\d)\.(?=(\s\S)|\))/, '∯') attr_reader :text def initialize(text:) @text = Text.new(text) end def replace @formatted_text = @text.apply(PeriodBeforeNumberRule). apply(NumberAfterPeriodBeforeLetterRule). apply(NewLineNumberPeriodSpaceLetterRule). apply(StartLineNumberPeriodRule). apply(StartLineTwoDigitNumberPeriodRule) end end end
Version data entries
4 entries across 4 versions & 1 rubygems