|
|
|
Bookmarklet for word counts on your YC application
|
|
3 points
by kaistinchcombe
4851 days ago
|
|
javascript: (function() { var wordCount = function() { if (!window.jQuery) { return setTimeout(wordCount, 100); } var $ = jQuery; $('.wc').remove(); $('textarea').each(function(idx,elem) { var wc = $(elem).text().split(/[ \n]+/).length; $(elem).after('<div class="wc"'+( (wc>120) ? ' style="color: red"':'')+'>'+wc+'</div>'); }); }; if (!window.jQuery) { var c=document.createElement("script"); c.type="text/javascript"; c.src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"; document.documentElement.childNodes[0].appendChild(c); } wordCount(); })(); https://gist.github.com/kstinchcombe/5087397/raw/6c6d6d852970a5b629a83f9ac6d55d701e0a3926/gistfile1.js doesn't update live, that would be super annoying. click again to update. |
|
----
lines = File.readlines("text.txt") line_count = lines.size text = lines.join total_characters = text.length total_characters_nospaces = text.gsub(/\s+/, '').length word_count = text.split.length sentence_count = text.split(/\.|\?|!/).length paragraph_count = text.split(/\n\n/).length
puts "This document contains:" puts "#{line_count} lines" puts "#{total_characters} characters" puts "#{total_characters_nospaces} characters excluding spaces" puts "#{word_count} words" puts "#{sentence_count} sentences." puts "#{paragraph_count} paragraphs." puts "#{sentence_count / paragraph_count} sentences per paragraph (average)" puts "#{word_count / sentence_count} words per sentence (average)"