at.tuwien.ifs.somtoolbox.data
Class AbstractSOMLibTemplateVector

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.data.AbstractSOMLibTemplateVector
All Implemented Interfaces:
TemplateVector
Direct Known Subclasses:
DataBaseSOMLibTemplateVector, SOMLibTemplateVector

public abstract class AbstractSOMLibTemplateVector
extends Object
implements TemplateVector

This abstract implementation provides basic support for operating on a TemplateVector. Sub-classes have to implement constructors and methods to read and create a template vector, e.g. from a file or a database.

Version:
$Id: AbstractSOMLibTemplateVector.java 3883 2010-11-02 17:13:23Z frank $
Author:
Michael Dittenbach, Rudolf Mayer

Field Summary
protected  int dim
          The dimension of the template vector, i.e.
protected  Hashtable<String,TemplateVectorElement> elementMap
          A mapping label --> attribute to allow fast access.
protected  TemplateVectorElement[] elements
          The attributes of the template vector.
protected  int longestStringLength
           
protected  int numInfo
           
protected  int numVectors
           
protected  String templateFileName
           
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.data.TemplateVector
templateFileNameSuffix
 
Constructor Summary
AbstractSOMLibTemplateVector()
           
 
Method Summary
 boolean containsLabel(String label)
          tests whether there is a feature/attribute with the given label
 int dim()
          Gets the dimension.
 int getDocumentFrequency(String label)
           
 TemplateVectorElement getElement(int index)
          returns the template vector element for the feature/attribute at the given position
 TemplateVectorElement getElement(String label)
           
 int getIndex(String label)
           
 int getIndexOfFeature(String label)
          Returns the numerical index of the feature with the given name.
 String getLabel(int i)
          Gets the label at the given index.
 String[] getLabels()
          Gets all the labels defined in this template vector.
 ArrayList<String> getLabelsAsList()
          Gets all the labels defined in this template vector as a list.
 int getLongestStringLength()
          calculates the length of the longest feature/attribute label
 double[] getTFxIDFVectorFromTerms(Hashtable<String,Integer> queryTerms)
           
 void incNumVectors(int numVectors)
          Increase the num-vectors counter, used e.g.
 int numinfo()
          Returns how many columns the template vector contains, i.e.
 int numVectors()
          Return how many vectors are in the input vector file associated with this template vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dim

protected int dim
The dimension of the template vector, i.e. the number of attributes.


numInfo

protected int numInfo

numVectors

protected int numVectors

templateFileName

protected String templateFileName

elements

protected TemplateVectorElement[] elements
The attributes of the template vector.


elementMap

protected Hashtable<String,TemplateVectorElement> elementMap
A mapping label --> attribute to allow fast access.


longestStringLength

protected int longestStringLength
Constructor Detail

AbstractSOMLibTemplateVector

public AbstractSOMLibTemplateVector()
Method Detail

dim

public int dim()
Description copied from interface: TemplateVector
Gets the dimension.

Specified by:
dim in interface TemplateVector
Returns:
the dimension of the template vector, i.e. the number of attributes

numVectors

public int numVectors()
Description copied from interface: TemplateVector
Return how many vectors are in the input vector file associated with this template vector

Specified by:
numVectors in interface TemplateVector

numinfo

public int numinfo()
Description copied from interface: TemplateVector
Returns how many columns the template vector contains, i.e. the $XDIM.

Specified by:
numinfo in interface TemplateVector

getLabel

public String getLabel(int i)
Description copied from interface: TemplateVector
Gets the label at the given index.

Specified by:
getLabel in interface TemplateVector
Returns:
the name of the label at the given index

getLabels

public String[] getLabels()
Description copied from interface: TemplateVector
Gets all the labels defined in this template vector.

Specified by:
getLabels in interface TemplateVector

getLabelsAsList

public ArrayList<String> getLabelsAsList()
Description copied from interface: TemplateVector
Gets all the labels defined in this template vector as a list.

Specified by:
getLabelsAsList in interface TemplateVector

getIndexOfFeature

public int getIndexOfFeature(String label)
Description copied from interface: TemplateVector
Returns the numerical index of the feature with the given name.

Specified by:
getIndexOfFeature in interface TemplateVector

getIndex

public int getIndex(String label)

getElement

public TemplateVectorElement getElement(String label)

containsLabel

public boolean containsLabel(String label)
Description copied from interface: TemplateVector
tests whether there is a feature/attribute with the given label

Specified by:
containsLabel in interface TemplateVector

getDocumentFrequency

public int getDocumentFrequency(String label)
Parameters:
label - the name of the term.
Returns:
The document frequency of the given term

getTFxIDFVectorFromTerms

public double[] getTFxIDFVectorFromTerms(Hashtable<String,Integer> queryTerms)
Parameters:
queryTerms - A map containing pairs for each term.
Returns:
A vector according to the tfxidf weighting scheme

getElement

public TemplateVectorElement getElement(int index)
Description copied from interface: TemplateVector
returns the template vector element for the feature/attribute at the given position

Specified by:
getElement in interface TemplateVector

getLongestStringLength

public int getLongestStringLength()
Description copied from interface: TemplateVector
calculates the length of the longest feature/attribute label

Specified by:
getLongestStringLength in interface TemplateVector

incNumVectors

public void incNumVectors(int numVectors)
Description copied from interface: TemplateVector
Increase the num-vectors counter, used e.g. when merging input files in SOMLibInputMerger .

Specified by:
incNumVectors in interface TemplateVector