Remove the stop words : select « String « Ruby
- Ruby
- String
- select
Remove the stop words
text = %q{this is a test.}
stop_words = %w{is a}
words = text.scan(/\w+/)
key_words = words.select { |word| !stop_words.include?(word) }
puts key_words.join(' ')
Related examples in the same category