Skip to content

Instantly share code, notes, and snippets.

@minjindang
Created September 3, 2015 08:33
Show Gist options
  • Save minjindang/47e76b582243eae0b21d to your computer and use it in GitHub Desktop.
Save minjindang/47e76b582243eae0b21d to your computer and use it in GitHub Desktop.
Coleman-Liau function
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;
}
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