pitt.search.semanticvectors
Class VectorStoreReaderText

java.lang.Object
  extended by pitt.search.semanticvectors.VectorStoreReaderText
All Implemented Interfaces:
CloseableVectorStore, VectorStore

public class VectorStoreReaderText
extends java.lang.Object
implements CloseableVectorStore

This class provides methods for reading a VectorStore from a textfile.

The textfile should start with an optional header line, "-dimensions|N".
All subsequent lines should be of the form
String|Num1|Num2|...|NumN

The serialization currently presumes that the object (in the ObjectVectors) should be serialized as a String.

This class is mainly for interoperability with plain text file formats: normal (fast) implementations should use the internal VectorStoreReader class that uses Lucene's I/O functions.

See Also:
VectorStoreReaderLucene, ObjectVector

Nested Class Summary
 class VectorStoreReaderText.VectorEnumerationText
          Implements the hasMoreElements() and nextElement() methods to give Enumeration interface from store in VectorTextFile.
 
Constructor Summary
VectorStoreReaderText(java.lang.String vectorFileText)
           
 
Method Summary
 void close()
          Release all filesystem or other resources that aren't automatically garbage collected.
 java.util.Enumeration getAllVectors()
           
 int getNumVectors()
          Trivial (costly) implementation of getNumVectors that iterates and counts vectors.
 float[] getVector(java.lang.Object desiredObject)
          Given an object, get its corresponding vector
This implementation only works for string objects so far
static ObjectVector parseVectorLine(java.lang.String line)
          Returns an object vector from a text line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorStoreReaderText

public VectorStoreReaderText(java.lang.String vectorFileText)
                      throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
Description copied from interface: CloseableVectorStore
Release all filesystem or other resources that aren't automatically garbage collected.

Specified by:
close in interface CloseableVectorStore

getAllVectors

public java.util.Enumeration getAllVectors()
Specified by:
getAllVectors in interface VectorStore
Returns:
an enumeration of all the object vectors in the store.

parseVectorLine

public static ObjectVector parseVectorLine(java.lang.String line)
                                    throws java.io.IOException
Returns an object vector from a text line.

Throws:
java.io.IOException

getVector

public float[] getVector(java.lang.Object desiredObject)
Given an object, get its corresponding vector
This implementation only works for string objects so far

Specified by:
getVector in interface VectorStore
Parameters:
desiredObject - - the string identifying the object being searched for.
Returns:
a vector (of floats)

getNumVectors

public int getNumVectors()
Trivial (costly) implementation of getNumVectors that iterates and counts vectors.

Specified by:
getNumVectors in interface VectorStore
Returns:
a count of the number of vectors in the store.