public static NavigableMap < String , Integer > loadVocab ( InputStream is ) throws IOException { final TreeMap < String , Integer > map = new TreeMap <> ( Collections . reverseOrder ( ) ) ; try ( final BufferedReader reader = new BufferedReader ( new InputStreamReader ( is ) ) ) { String token ; int i = 0 ; while ( ( token = reader . readLine ( ) ) != null ) { map . put ( token , i ++ ) ; } } return map ; }
The expected format is a \ n seperated list of tokens for examples