Created
September 3, 2015 08:33
-
-
Save minjindang/47e76b582243eae0b21d to your computer and use it in GitHub Desktop.
Coleman-Liau function
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
function colemanLiau(counts) { | |
var LETTER_WEIGHT = 0.0588; | |
var SENTENCE_WEIGHT = 0.296; | |
var BASE = 15.8; | |
var PERCENTAGE = 100; | |
if (!counts || !counts.sentence || !counts.word || !counts.letter) { | |
return NaN; | |
} | |
return LETTER_WEIGHT * (counts.letter / counts.word * PERCENTAGE) - | |
SENTENCE_WEIGHT * (counts.sentence / counts.word * PERCENTAGE) - | |
BASE; | |
} |
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
colemanLiau({'sentence': 5,'word': 119,'letter': 639}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment