private void loadOffsetsFromFormat ( File file , SSpaceFormat format ) throws IOException { this . format = format ; spaceName = file . getName ( ) ; // NOTE: Use a LinkedHashMap here because this will ensure that the // words are returned in the same row-order as the matrix. This // generates better disk I/O behavior for accessing the matrix since // each word is directly after the previous on disk. termToOffset = new LinkedHashMap < String , Long > ( ) ; long start = System . currentTimeMillis ( ) ; int dims = - 1 ; RandomAccessFile raf = null ; RandomAccessBufferedReader lnr = null ; switch ( format ) { case TEXT : lnr = new RandomAccessBufferedReader ( file ) ; dims = loadTextOffsets ( lnr ) ; break ; case BINARY : raf = new RandomAccessFile ( file , "r" ) ; dims = loadBinaryOffsets ( raf ) ; break ; case SPARSE_TEXT : lnr = new RandomAccessBufferedReader ( file ) ; dims = loadSparseTextOffsets ( lnr ) ; break ; case SPARSE_BINARY : raf = new RandomAccessFile ( file , "r" ) ; dims = loadSparseBinaryOffsets ( raf ) ; break ; default : assert false : format ; } if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . fine ( "loaded " + format + " .sspace file in " + ( System . currentTimeMillis ( ) - start ) + "ms" ) ; } this . dimensions = dims ; this . binarySSpace = raf ; this . textSSpace = lnr ; }
Loads the words and offets for each word s vector in the semantic space file using the format as a guide to how the semantic space data is stored in the file .