Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.parser
Class SparseFloatVectorLabelParser

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.parser.AbstractParser<V>
              extended by de.lmu.ifi.dbs.elki.parser.RealVectorLabelParser<SparseFloatVector>
                  extended by de.lmu.ifi.dbs.elki.parser.SparseFloatVectorLabelParser
All Implemented Interfaces:
LinebasedParser<SparseFloatVector>, Parser<SparseFloatVector>, Parameterizable

public class SparseFloatVectorLabelParser
extends RealVectorLabelParser<SparseFloatVector>

Provides a parser for parsing one point per line, attributes separated by whitespace.

Several labels may be given per point. A label must not be parseable as double. Lines starting with "#" will be ignored.

A line is expected in the following format: The first entry of each line is the number of attributes with coordinate value not zero. Subsequent entries are of the form (index, value), where index is the number of the corresponding dimension, and value is the value of the corresponding attribute.

An index can be specified to identify an entry to be treated as class label. This index counts all entries (numeric and labels as well) starting with 0.

Author:
Arthur Zimek

Field Summary
private  int dimensionality
          Holds the dimensionality of the parsed data which is the maximum occurring index of any attribute.
 
Fields inherited from class de.lmu.ifi.dbs.elki.parser.RealVectorLabelParser
CLASS_LABEL_INDEX_PARAM, classLabelIndex
 
Fields inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
ATTRIBUTE_CONCATENATION, COMMENT, WHITESPACE_PATTERN
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
SparseFloatVectorLabelParser()
           
 
Method Summary
 SparseFloatVector createDBObject(List<Double> attributes)
          Creates a DoubleVector out of the given attribute values.
protected  String descriptionLineType()
           
 ParsingResult<SparseFloatVector> parse(InputStream in)
          Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.
 Pair<SparseFloatVector,List<String>> parseLine(String line)
          Parse a single line into a database object
 String shortDescription()
          Returns a short description of the class.
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.RealVectorLabelParser
setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
toString
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters
 

Field Detail

dimensionality

private int dimensionality
Holds the dimensionality of the parsed data which is the maximum occurring index of any attribute.

Constructor Detail

SparseFloatVectorLabelParser

public SparseFloatVectorLabelParser()
Method Detail

createDBObject

public SparseFloatVector createDBObject(List<Double> attributes)
Creates a DoubleVector out of the given attribute values.

Specified by:
createDBObject in class RealVectorLabelParser<SparseFloatVector>
Parameters:
attributes - the attributes of the vector to create.
Returns:
a RalVector of type V containing the given attribute values
See Also:
RealVectorLabelParser.createDBObject(java.util.List)

descriptionLineType

protected String descriptionLineType()
Specified by:
descriptionLineType in class RealVectorLabelParser<SparseFloatVector>
See Also:
RealVectorLabelParser.descriptionLineType()

parseLine

public Pair<SparseFloatVector,List<String>> parseLine(String line)
Description copied from interface: LinebasedParser
Parse a single line into a database object

Specified by:
parseLine in interface LinebasedParser<SparseFloatVector>
Overrides:
parseLine in class RealVectorLabelParser<SparseFloatVector>
Parameters:
line - single line
Returns:
parsing result
See Also:
RealVectorLabelParser.parseLine(java.lang.String)

parse

public ParsingResult<SparseFloatVector> parse(InputStream in)
Description copied from interface: Parser
Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.

Specified by:
parse in interface Parser<SparseFloatVector>
Overrides:
parse in class RealVectorLabelParser<SparseFloatVector>
Parameters:
in - the stream to parse objects from
Returns:
a list containing those objects parsed from the input stream and their associated labels.
See Also:
RealVectorLabelParser.parse(java.io.InputStream)

shortDescription

public String shortDescription()
Description copied from class: AbstractParameterizable
Returns a short description of the class.

Specified by:
shortDescription in interface Parameterizable
Overrides:
shortDescription in class RealVectorLabelParser<SparseFloatVector>
Returns:
Description of the class
See Also:
RealVectorLabelParser.shortDescription()

Release 0.2 (2009-07-06_1820)