Created
April 28, 2013 04:14
-
-
Save jnewman12/5475845 to your computer and use it in GitHub Desktop.
This is used for summarizing text. For the time being, just insert your own text into the text variable. I will see if I can add more to it
This file contains 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
text = %q{ | |
#insert your text here | |
} | |
sentences = text.gsub(/\s+/, ' ').strip.split(/\.|\?|!/) | |
sentences_sorted = sentences.sort_by {|sentence| sentence.length} | |
one_third = sentences_sorted.length / 3 | |
ideal_sentences = sentences_sorted.slice(one_third, one_third + 1) | |
ideal_sentences = ideal_sentences.select { |sentence| sentence =~ /is|are/ } | |
puts ideal_sentences.join(". ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment