Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/nlp_toolz/helpers/string_extended.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



17
18
19
# File 'lib/nlp_toolz/helpers/string_extended.rb', line 17

def basename
  self.split("/").last
end

#clean_upObject

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)
  bar = 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
  bar
end