public static Set < String > readStopwords ( BufferedReader reader ) throws IOException { HashSet < String > words = new HashSet < String > ( ) ; String nextLine ; while ( ( ( nextLine = reader . readLine ( ) ) != null ) ) { words . add ( nextLine . trim ( ) . toLowerCase ( ) ) ; } return words ; }
Read stopwords in memory from a file one per line . Stopwords are converted to lowercase when read .