public static ImmutableSet < String > lowercaseWordSet ( final Class < ? > origin , final String resource , final boolean eliminatePrepAndConj ) throws IOException { return ImmutableSet . copyOf ( new HashSet < String > ( ) { { readResource ( origin , resource , new NullReturnLineProcessor ( ) { @ Override public boolean processLine ( @ Nonnull final String line ) { final String l = simplify ( line ) ; if ( ! l . isEmpty ( ) && ! l . startsWith ( "#" ) ) { for ( final String part : SPACES . split ( l ) ) { if ( eliminatePrepAndConj ) { final String wordType = Dictionary . checkup ( part ) ; if ( wordType != null && ( wordType . startsWith ( "IN" ) || wordType . startsWith ( "CC" ) ) ) { continue ; } } // add to the containing HashSet we are currently in the init block of add ( toEngLowerCase ( clean ( part ) ) ) ; } } return true ; } } ) ; } } ) ; }
Returns a Set containing only single words .