at.tuwien.ifs.somtoolbox.data
Class SOMLibTemplateVector

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

public class SOMLibTemplateVector
extends AbstractSOMLibTemplateVector

Implements a TemplateVector based on a SOMLib Template Vector File. See also a sample TemplateVector file.

Created on May 14, 2004

Version:
$Id: SOMLibTemplateVector.java 3583 2010-05-21 10:07:41Z mayer $
Author:
Michael Dittenbach, Rudolf Mayer

Field Summary
private  int lineNumber
           
 
Fields inherited from class at.tuwien.ifs.somtoolbox.data.AbstractSOMLibTemplateVector
dim, elementMap, elements, longestStringLength, numInfo, numVectors, templateFileName
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.data.TemplateVector
templateFileNameSuffix
 
Constructor Summary
protected SOMLibTemplateVector()
          Creates an empty instance.
  SOMLibTemplateVector(int numVectors, int dim)
          Constructor intended to be used when generating data.
  SOMLibTemplateVector(int numVectors, String[] componentNames)
          Creates an instance with the given component names.
  SOMLibTemplateVector(int numVectors, String[] componentNames, int numInfo)
          Creates an instance with the given component names, and the specified detail level numInfo
  SOMLibTemplateVector(String templateFileName)
          Creates a new TemplateVector by reading from the given file.
 
Method Summary
private  String getErrorDetails(String line, int lineNumber)
           
private  String getErrorMessage(String messageDetail, String line, int lineNumber)
           
protected  void processLine(int index, String[] lineElements)
          Parse information from one single line in the TemplateVector file, representing one attribute.
 void readTemplateVectorFile(String templateFileName)
          Reads the TemplateVector information from the given filename.
protected  String readTemplateVectorFileHeader(BufferedReader br)
           
 void setComponentNames(String[] componentNames)
          Sets the names of the vector elements.
 void setLabel(int index, String label)
           
 
Methods inherited from class at.tuwien.ifs.somtoolbox.data.AbstractSOMLibTemplateVector
containsLabel, dim, getDocumentFrequency, getElement, getElement, getIndex, getIndexOfFeature, getLabel, getLabels, getLabelsAsList, getLongestStringLength, getTFxIDFVectorFromTerms, incNumVectors, numinfo, numVectors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineNumber

private int lineNumber
Constructor Detail

SOMLibTemplateVector

protected SOMLibTemplateVector()
Creates an empty instance.


SOMLibTemplateVector

public SOMLibTemplateVector(int numVectors,
                            int dim)
Constructor intended to be used when generating data. All attributes will be called "componen_x".


SOMLibTemplateVector

public SOMLibTemplateVector(int numVectors,
                            String[] componentNames,
                            int numInfo)
                     throws IOException
Creates an instance with the given component names, and the specified detail level numInfo

Throws:
IOException

SOMLibTemplateVector

public SOMLibTemplateVector(int numVectors,
                            String[] componentNames)
                     throws IOException
Creates an instance with the given component names.

Throws:
IOException

SOMLibTemplateVector

public SOMLibTemplateVector(String templateFileName)
                     throws IOException
Creates a new TemplateVector by reading from the given file.

Parameters:
templateFileName - the file to read from
Throws:
IOException - in case of problems reading the file
Method Detail

readTemplateVectorFile

public void readTemplateVectorFile(String templateFileName)
                            throws IOException
Reads the TemplateVector information from the given filename. The file format has to follow the specification given in the SOMLib Data Files specification. See also a sample TemplateVector file.

Throws:
IOException

readTemplateVectorFileHeader

protected String readTemplateVectorFileHeader(BufferedReader br)
                                       throws IOException
Throws:
IOException

getErrorMessage

private String getErrorMessage(String messageDetail,
                               String line,
                               int lineNumber)

getErrorDetails

private String getErrorDetails(String line,
                               int lineNumber)

processLine

protected void processLine(int index,
                           String[] lineElements)
Parse information from one single line in the TemplateVector file, representing one attribute.

Parameters:
index - the index (number) of this attribute
lineElements - the elements of this line, split by the delimiter

setComponentNames

public void setComponentNames(String[] componentNames)
Sets the names of the vector elements.


setLabel

public void setLabel(int index,
                     String label)