Created
July 14, 2011 15:21
-
-
Save kenshin03/1082659 to your computer and use it in GitHub Desktop.
scoring doc by readability
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
double readabilityMean = 0.0; | |
if (readabilityText != null){ | |
BasicDBObject readabilityScoresObj = new BasicDBObject(); | |
readabilityScoresObj.put("text", readabilityText); | |
BagOfReadabilityObjects readabilityStats = new Readability(readabilityText).getMetrics(); | |
double normalizedFlesch = (100 - Math.abs(readabilityStats.getFleschReading() - 50))/100; | |
double normalizedFleschKincaid = (16 - Math.abs(readabilityStats.getFleschReading() - 13))/16; | |
double normalizedARI = (16 - Math.abs(readabilityStats.getARI() - 13))/16; | |
double normalizedLiau = (16 - Math.abs(readabilityStats.getColemanLiau() - 13))/16; | |
double normalizedGunning = (16 - Math.abs(readabilityStats.getGunningFog() - 12))/16; | |
double normalizedSMOG = (16 - Math.abs(readabilityStats.getSMOGIndex() - 12))/16; | |
readabilityMean = (normalizedFlesch + normalizedFleschKincaid + normalizedARI+ normalizedLiau + normalizedGunning + normalizedSMOG)/6; | |
readabilityScoresObj.put("mean", Double.valueOf(new DecimalFormat("#.####").format(readabilityMean))); | |
dbObj.put("readability", readabilityScoresObj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment