Module: Treat::Helpers::String::Escapable
- Defined in:
- lib/treat/helpers/string.rb
Overview
Utility to escape floating point numbers from strings (useful for a variety of applications, including chunking, segmenting and tokenizing, to exclude periods that are not sentence terminators).
Constant Summary collapse
- EscapeChar =
Escape char to use.
'^^^'
- Regex =
Regex for escape.
/([0-9]+)\.([0-9]+)/
Instance Method Summary collapse
-
#escape_floats! ⇒ Object
Escape float periods with EscapeChar.
Instance Method Details
#escape_floats! ⇒ Object
Escape float periods with EscapeChar.
18 19 20 |
# File 'lib/treat/helpers/string.rb', line 18 def escape_floats! to_s.gsub!(Regex) { $1 + EscapeChar + $2 } end |