de.pado.dv
Class SemanticSpaceArray

java.lang.Object
  extended by de.pado.dv.SemanticSpaceArray
All Implemented Interfaces:
SemanticSpace

public class SemanticSpaceArray
extends java.lang.Object
implements SemanticSpace

This is a naive array-based implementation of the SemanticSpace interface. It is rather fast, but requires much memory (number(targets)*number(basis elements)*size(Double)).


Method Summary
 boolean containsBE(java.lang.String b)
          Determines if the basis element b is used for representation in the semantic space.
 boolean containsTarget(java.lang.String t)
          Determines if the target t is represented in the semantic space.
 void fillFromFile(java.lang.String matrixfilename)
          Fill a semantic space with the data from a string represtation of the space in a file.
 double[] getVector(java.lang.String target)
          Returns the vector representing the target as a double array.
 void increaseCount(java.lang.String target, java.lang.String be, double value)
          Increases the co-occurrence count for a given target and basis element combination.
 void loglikelihood(double total)
          Performs a log-likelihood transformation for all the cells in the space matrix.
 void setCount(java.lang.String target, java.lang.String be, double value)
          Sets the co-occurrence count for a given target and basis element combination to some number.
 java.lang.String toString()
          Returns a string representation of the SemanticSpace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

increaseCount

public void increaseCount(java.lang.String target,
                          java.lang.String be,
                          double value)
Increases the co-occurrence count for a given target and basis element combination.

Specified by:
increaseCount in interface SemanticSpace

setCount

public void setCount(java.lang.String target,
                     java.lang.String be,
                     double value)
Sets the co-occurrence count for a given target and basis element combination to some number.


loglikelihood

public void loglikelihood(double total)
Performs a log-likelihood transformation for all the cells in the space matrix. Requires the total number of co-occurrences seen for the production of the given space to use the marginals for efficient estimation. The present implementation is copied from Scott McDonald's vector.pl script.


containsTarget

public boolean containsTarget(java.lang.String t)
Description copied from interface: SemanticSpace
Determines if the target t is represented in the semantic space.

Specified by:
containsTarget in interface SemanticSpace

containsBE

public boolean containsBE(java.lang.String b)
Description copied from interface: SemanticSpace
Determines if the basis element b is used for representation in the semantic space.

Specified by:
containsBE in interface SemanticSpace

getVector

public double[] getVector(java.lang.String target)
Returns the vector representing the target as a double array.


toString

public java.lang.String toString()
Returns a string representation of the SemanticSpace. The format follows the old McDonald file format. First line: list of basis elements (tab-separated). All following lines contain first a target, then a colon, and then space-separated double values. Both targets and basis elements are ordered naturally (lexicographically). Notice that the resulting string object can become quite large due to the representation of floating point values by up to 16 characters each. It should probably be possible (but is not implemented) to specify the number of decimal places.

Specified by:
toString in interface SemanticSpace
Overrides:
toString in class java.lang.Object

fillFromFile

public void fillFromFile(java.lang.String matrixfilename)
                  throws java.io.IOException
Fill a semantic space with the data from a string represtation of the space in a file.

Throws:
java.io.IOException