public class StaticSemanticSpace extends Object implements SemanticSpace
SemanticSpace
whose data is loaded into memory from
an .sspace
file. Instance of this class perform no document
processing, and the processDocument
and processSpace
methods
throw an UnsupportedOperationException
.
In general, users should call SemanticSpaceUtils.loadSemanticSpace(File)
rather than create an instance of
this class directly.
This class is thread-safe
OnDiskSemanticSpace
,
SemanticSpaceUtils
,
SemanticSpaceUtils.SSpaceFormat
Constructor and Description |
---|
StaticSemanticSpace(File file)
Creates the
StaticSemanticSpace from the provided file. |
StaticSemanticSpace(File file,
SemanticSpaceIO.SSpaceFormat format)
Deprecated.
|
StaticSemanticSpace(String filename)
Creates the
StaticSemanticSpace from the file. |
Modifier and Type | Method and Description |
---|---|
String |
getSpaceName()
Returns a unique string describing the name and configuration of this
algorithm.
|
Vector |
getVector(String term)
Returns the semantic vector for the provided word.
|
int |
getVectorLength()
Returns the length of vectors in this semantic space.
|
Set<String> |
getWords()
Returns the set of words that are represented in this semantic space.
|
void |
processDocument(BufferedReader document)
Not supported; throws an
UnsupportedOperationException if called. |
void |
processSpace(Properties props)
Not supported; throws an
UnsupportedOperationException if called. |
public StaticSemanticSpace(String filename) throws IOException
StaticSemanticSpace
from the file.filename
- the name of a file containing SemanticSpace
data.IOException
- if any I/O exception occurs when reading the semantic
space data from the filepublic StaticSemanticSpace(File file) throws IOException
StaticSemanticSpace
from the provided file.file
- a file containing the data of a SemanticSpace
.IOException
- if any I/O exception occurs when reading the semantic
space data from the file@Deprecated public StaticSemanticSpace(File file, SemanticSpaceIO.SSpaceFormat format) throws IOException
StaticSemanticSpace
from the provided file in the
specified format. This method is only to be used in accessing SemanticSpace
files that do not include the format in their file
contents.file
- a file containing the data of a SemanticSpace
.format
- the format of the semantic spaceIOException
- if any I/O exception occurs when reading the semantic
space data from the filepublic Set<String> getWords()
getWords
in interface SemanticSpace
public Vector getVector(String term)
getVector
in interface SemanticSpace
term
- a word that may be in the semantic spaceVector
for the provided word or null
if the
word was not in the space.public String getSpaceName()
getSpaceName
in interface SemanticSpace
public int getVectorLength()
processSpace
is called.getVectorLength
in interface SemanticSpace
public void processDocument(BufferedReader document)
UnsupportedOperationException
if called.processDocument
in interface SemanticSpace
document
- a reader that allows access to the text of the documentan
- UnsupportedOperationException
if calledpublic void processSpace(Properties props)
UnsupportedOperationException
if called.processSpace
in interface SemanticSpace
props
- a set of properties and values that may be used to
configure any exposed parameters of the algorithm.an
- UnsupportedOperationException
if calledCopyright © 2012. All Rights Reserved.