public static boolean read(final File vocab_file) throws IOException {
  DataInputStream vocab_stream=new DataInputStream(new BufferedInputStream(new FileInputStream(vocab_file)));
  int size=vocab_stream.readInt();
  LOG.info("Read {} entries from the vocabulary",size);
  clear();
  for (int i=0; i < size; i++) {
    int id=vocab_stream.readInt();
    String token=vocab_stream.readUTF();
    if (id != Math.abs(id(token))) {
      vocab_stream.close();
      return false;
    }
  }
  vocab_stream.close();
  return (size + 1 == idToString.size());
}

public static boolean read ( final File vocab_file ) throws IOException { DataInputStream vocab_stream = new DataInputStream ( new BufferedInputStream ( new FileInputStream ( vocab_file ) ) ) ; int size = vocab_stream . readInt ( ) ; LOG . info ( "Read {} entries from the vocabulary" , size ) ; clear ( ) ; for ( int i = 0 ; i < size ; i ++ ) { int id = vocab_stream . readInt ( ) ; String token = vocab_stream . readUTF ( ) ; if ( id != Math . abs ( id ( token ) ) ) { vocab_stream . close ( ) ; return false ; } } vocab_stream . close ( ) ; return ( size + 1 == idToString . size ( ) ) ; }
reads a vocabulary from file . this deletes any additions to the vocabulary made prior to reading the file .
