public List < String > keywords ( final String source ) { Map < String , Long > wordCounts = splitChars ( source , DEFAULT_THRESHOLD ) . stream ( ) . collect ( Collectors . groupingBy ( x -> x , Collectors . counting ( ) ) ) ; wordCounts = aggregateKeywords ( wordCounts ) ; return wordCounts . entrySet ( ) . stream ( ) . filter ( x -> x . getValue ( ) > 1 ) . sorted ( Comparator . comparing ( x -> - entropy ( x . getKey ( ) ) * Math . pow ( x . getValue ( ) , 0.3 ) ) ) . map ( e -> { if ( isVerbose ( ) ) { verbose . println ( String . format ( "KEYWORD: \"%s\" - %s * %.3f / %s" , e . getKey ( ) , e . getValue ( ) , entropy ( e . getKey ( ) ) , e . getKey ( ) . length ( ) ) ) ; } return e . getKey ( ) ; } ) . collect ( Collectors . toList ( ) ) ; }
Keywords list .