private Map loadBinaryLexicon(InputStream is,int estimatedSize) throws IOException {
  DataInputStream dis=new DataInputStream(new BufferedInputStream(is));
  int size=0;
  int numEntries=0;
  List phonemeList=new ArrayList();
  Map lexicon=new LinkedHashMap();
  int magic;
  try {
    if (dis.readInt() != MAGIC) {
      throw new Error("bad magic number in lexicon");
    }
  }
 catch (  IOException e) {
    throw e;
  }
  if (dis.readInt() != VERSION) {
    throw new Error("bad version number in lexicon");
  }
  size=dis.readInt();
  for (int i=0; i < size; i++) {
    String phoneme=getString(dis);
    phonemeList.add(phoneme);
  }
  numEntries=dis.readInt();
  for (int i=0; i < numEntries; i++) {
    String wordAndPos=getString(dis);
    String pos=Character.toString(wordAndPos.charAt(wordAndPos.length() - 1));
    if (!partsOfSpeech.contains(pos)) {
      partsOfSpeech.add(pos);
    }
    int numPhonemes=dis.readByte();
    String[] phonemes=new String[numPhonemes];
    for (int j=0; j < numPhonemes; j++) {
      phonemes[j]=(String)phonemeList.get(dis.readByte());
    }
    lexicon.put(wordAndPos,phonemes);
  }
  dis.close();
  return lexicon;
}

private Map loadBinaryLexicon ( InputStream is , int estimatedSize ) throws IOException { DataInputStream dis = new DataInputStream ( new BufferedInputStream ( is ) ) ; int size = 0 ; int numEntries = 0 ; List phonemeList = new ArrayList ( ) ; Map lexicon = new LinkedHashMap ( ) ; int magic ; try { if ( dis . readInt ( ) != MAGIC ) { throw new Error ( "bad magic number in lexicon" ) ; } } catch ( IOException e ) { throw e ; } if ( dis . readInt ( ) != VERSION ) { throw new Error ( "bad version number in lexicon" ) ; } size = dis . readInt ( ) ; for ( int i = 0 ; i < size ; i ++ ) { String phoneme = getString ( dis ) ; phonemeList . add ( phoneme ) ; } numEntries = dis . readInt ( ) ; for ( int i = 0 ; i < numEntries ; i ++ ) { String wordAndPos = getString ( dis ) ; String pos = Character . toString ( wordAndPos . charAt ( wordAndPos . length ( ) - 1 ) ) ; if ( ! partsOfSpeech . contains ( pos ) ) { partsOfSpeech . add ( pos ) ; } int numPhonemes = dis . readByte ( ) ; String [ ] phonemes = new String [ numPhonemes ] ; for ( int j = 0 ; j < numPhonemes ; j ++ ) { phonemes [ j ] = ( String ) phonemeList . get ( dis . readByte ( ) ) ; } lexicon . put ( wordAndPos , phonemes ) ; } dis . close ( ) ; return lexicon ; }
loads the binary lexicon from the given inputstream . this method is not thread safe .
