public static double spacheScore ( String strText ) { //http://simple.wikipedia.org/wiki/Spache_Readability_Formula strText = cleanText ( strText ) ; int intUniqueUnfamiliarWordCount = 0 ; Set < String > arrWords = new HashSet <> ( ( new WhitespaceTokenizer ( ) ) . tokenize ( strText ) ) ; for ( String word : arrWords ) { if ( ! SPACHE_WORDLIST . contains ( word ) ) { ++ intUniqueUnfamiliarWordCount ; } } int intSentenceCount = sentenceCount ( strText ) ; int intWordCount = wordCount ( strText ) ; return 0.121 * intWordCount / ( double ) intSentenceCount + 0.082 * intUniqueUnfamiliarWordCount + 0.659 ; }
Returns the Spache Score of the text .