Last active
November 6, 2018 22:23
-
-
Save markschwarz/f5ca58712034bcd5d3d91084eb71da4d to your computer and use it in GitHub Desktop.
Word and Character Count service for Mac OS X
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
-- Word and Character Count service for Mac OS X | |
-- Adds a Word and Character Count option to the text selection context menu | |
-- Use Automator to create a new service, then select the Run AppleScript action. Make | |
-- sure the service is set to receive "text", at the top of the window. Paste in this code | |
-- and save as "Word and Character Count". Now switch to a new app, select some text, | |
-- right-click, go to Services, and find the new option. | |
-- Copyright 2015, Noah Slater <[email protected]> | |
-- Copying and distribution of this file, with or without modification, are permitted in | |
-- any medium without royalty provided the copyright notice and this notice are preserved. | |
-- This file is offered as-is, without any warranty. | |
-- mschwarz: Added constants for more readable results: | |
-- 17 words/sentence: https://strainindex.wordpress.com/2008/07/28/the-average-sentence-length/ | |
-- 2.33 words/second: http://www.drewsmarketingminute.com/2007/01/60_ticks_market_3.html | |
-- Limit answers in media interviews to 30 seconds: http://www.mrmediatraining.com/2014/02/25/how-long-should-your-media-answers-be/ | |
-- 300 WPM reading speed, per https://www.forbes.com/sites/brettnelson/2012/06/04/do-you-read-fast-enough-to-be-successful/#4e338859462e | |
on run {input, parameters} | |
tell application "System Events" | |
set _appname to name of first process whose frontmost is true | |
end tell | |
set word_count to count words of (input as string) | |
set sentence_count to (word_count / 17) as integer | |
set verbal_seconds_count to (word_count / 2.33) as integer | |
set reading_seconds_count to (word_count / 5) as integer | |
tell application _appname | |
display alert "" & word_count & " words, or roughly " & sentence_count & " succinct sentences. | |
This is about " & verbal_seconds_count & " seconds of spoken text. | |
It should take the average reader " & reading_seconds_count & " seconds to read silently. | |
Speaking rule of thumb: Most modern English communicators make statements in 3-4 sentences, in fewer than 30 seconds." | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment