Method: Clarifier::StopWords#clarify

Defined in:
lib/clarifier/stop_words.rb

#clarify(input) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/clarifier/stop_words.rb', line 23

def clarify(input)
  new_string = input.dup

  @stopwords.each do |word|
    new_string.gsub!(/(^|\s)#{Regexp.escape(word)}(\s|$)/i, '\1\2')
  end

  new_string.gsub!(/\s+/, ' ')
  new_string.strip!

  new_string
end