Last active
December 14, 2015 04:19
-
-
Save kkxlkkxllb/5027248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| content = "Meet Mr. Jon. Jon is a computer programmer and lives in Connecticut. Jon is tall. Shouldn't take web 2.0 as two sentences. And this is a new sentence. " | |
| words = {} | |
| content.gsub!(/(Mr)\.|(Mrs)\./,"\\1{dot}").split(/\. |\? |\! /).each_with_index do |sentences, index| | |
| puts "\n#{index}: #{sentences}" | |
| sentences.split(/ +/).each do |word| | |
| word=word.gsub(/{dot}/,"\.").downcase | |
| puts word | |
| words[word]=words[word]||[0,[]] | |
| words[word][0]+=1 | |
| words[word][1]<<index | |
| end | |
| end | |
Author
kkxlkkxllb
commented
Feb 26, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment