INNER CODE UNIT · Ruby
replace_multi_period_abbreviations
grobidOrg/grobid · grobid-home/sentence-segmentation/pragmatic_segmenter/abbreviation_replacer.rb:90
def replace_multi_period_abbreviations(txt)
mpa = txt.scan(@language::MULTI_PERIOD_ABBREVIATION_REGEX)
return txt if mpa.empty?
mpa.each do |r|
txt.gsub!(/#{Regexp.escape(r)}/, "#{r.gsub!('.', '∯')}")
end
txt
end
def replace_pre_number_abbr(txt, abbr)
txt.gsub!(/(?<=\s#{abbr.strip})\.(?=\s\d)|(?<=^#{abbr.strip})\.(?=\s\d)/, '∯')
txt.gsub!(/(?<=\s#{abbr.strip})\.(?=\s+\()|(?<=^#{abbr.strip})\.(?=\s+\()/, '∯')
txt
end
def replace_prepositive_abbr(txt, abbr)
txt.gsub!(/(?<=\s#{abbr.strip})\.(?=\s)|(?<=^#{abbr.strip})\.(?=\s)/, '∯')
txt.gsub!(/(?<=\s#{abbr.strip})\.(?=:\d+)|(?<=^#{abbr.strip})\.(?=:\d+)/, '∯')