Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/nlp_toolz/helpers/string_extended.rb
Instance Method Summary collapse
- #basename ⇒ Object
-
#clean_up ⇒ Object
ToDo: check abbr against list of ..
Instance Method Details
#basename ⇒ Object
17 18 19 |
# File 'lib/nlp_toolz/helpers/string_extended.rb', line 17 def basename self.split("/").last end |
#clean_up ⇒ Object
ToDo: check abbr against list of ..
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nlp_toolz/helpers/string_extended.rb', line 6 def clean_up foo = self.encode('UTF-8', :invalid => :replace, :undef => :replace) = foo.gsub(/[\p{Pi}\p{Pf}"'„“‘’“”«»‹›]/,'') # quotation marks .gsub(/\b\/\b/,' ') .gsub(/(\p{Ps})(.)/,'\1 \2') # left braces .gsub(/(.)(\p{Pe})/,'\1 \2') # right braces .gsub(/([\w]{3,})([\.])/,'\1 \2') # abbrevation? .gsub(/(.)([,;:!?]+)/,'\1 \2') # punctation end |