private void loadFromFormat ( InputStream is , SSpaceFormat format ) throws IOException { // 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. termToIndex = new LinkedHashMap < String , Integer > ( ) ; Matrix m = null ; long start = System . currentTimeMillis ( ) ; switch ( format ) { case TEXT : m = Matrices . synchronizedMatrix ( loadText ( is ) ) ; break ; case BINARY : m = Matrices . synchronizedMatrix ( loadBinary ( is ) ) ; break ; // REMINDER: we don't use synchronized here because the current // sparse matrix implementations are thread-safe. We really should // be aware of this for when the file-based sparse matrix gets // implemented. -jurgens 05/29/09 case SPARSE_TEXT : m = loadSparseText ( is ) ; break ; case SPARSE_BINARY : m = loadSparseBinary ( is ) ; break ; } if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . fine ( "loaded " + format + " .sspace file in " + ( System . currentTimeMillis ( ) - start ) + "ms" ) ; } wordSpace = m ; }
Loads the semantic space data from the specified stream using the format to determine how the data is layed out internally within the stream .