Remove the stop words : select « String « Ruby






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

1.Get sentences from a paragraph