Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Last active December 10, 2015 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChangJoo-Park/4374582 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/4374582 to your computer and use it in GitHub Desktop.
불용어를 제외하고 보여줌
# encoding: utf-8
# Stop_words 2012-12-26
stop_words = %w{the a by on for of are with just but and to the my I has some in}
text=%q{Korea is officially the only divided nation in the world.}
words = text.scan(/\w+/)
key_words = words.select { |word| !stop_words.include?(word)}
puts "문장 중 키워드의 비율은 : #{((key_words.length.to_f/words.length.to_f)*100).to_i}%"
puts key_words.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment