Sha256: 4e201db95b6f2d8fff26906f3461a83dcee74301c93c521ecf705ef674d157c8
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 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 @text.apply PeriodBeforeNumberRule, NumberAfterPeriodBeforeLetterRule, NewLineNumberPeriodSpaceLetterRule, StartLineNumberPeriodRule, StartLineTwoDigitNumberPeriodRule end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pragmatic_segmenter-0.3.3 | lib/pragmatic_segmenter/number.rb |
pragmatic_segmenter-0.3.2 | lib/pragmatic_segmenter/number.rb |