Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.parser
Class NumberVectorLabelParser<V extends NumberVector<?,?>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.parser.AbstractParser<V>
          extended by de.lmu.ifi.dbs.elki.parser.NumberVectorLabelParser<V>
Type Parameters:
V - the type of NumberVector expected in the ParsingResult
All Implemented Interfaces:
LinebasedParser<V>, Parser<V>, Parameterizable
Direct Known Subclasses:
DoubleVectorLabelParser, FloatVectorLabelParser, SparseFloatVectorLabelParser

public abstract class NumberVectorLabelParser<V extends NumberVector<?,?>>
extends AbstractParser<V>
implements LinebasedParser<V>, Parameterizable

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.

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 static OptionID LABEL_INDICES_ID
          OptionID for LABEL_INDICES_PARAM
private  IntListParameter LABEL_INDICES_PARAM
          A comma separated list of the indices of labels (may be numeric), counting whitespace separated entries in a line starting with 0.
protected  BitSet labelIndices
          Keeps the indices of the attributes to be treated as a string label.
 
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.logging.AbstractLoggable
debug, logger
 
Constructor Summary
NumberVectorLabelParser(Parameterization config)
          Constructor, adhering to Parameterizable
 
Method Summary
protected abstract  V createDBObject(List<Double> attributes)
           Creates a database object of type V.
 ParsingResult<V> 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<V,List<String>> parseLine(String line)
          Parse a single line into a database object
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
toString
 
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
 

Field Detail

LABEL_INDICES_ID

private static final OptionID LABEL_INDICES_ID
OptionID for LABEL_INDICES_PARAM


LABEL_INDICES_PARAM

private final IntListParameter LABEL_INDICES_PARAM
A comma separated list of the indices of labels (may be numeric), counting whitespace separated entries in a line starting with 0. The corresponding entries will be treated as a label.

Key: -parser.labelIndices


labelIndices

protected BitSet labelIndices
Keeps the indices of the attributes to be treated as a string label.

Constructor Detail

NumberVectorLabelParser

public NumberVectorLabelParser(Parameterization config)
Constructor, adhering to Parameterizable

Parameters:
config - Parameterization
Method Detail

parse

public ParsingResult<V> 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<V extends NumberVector<?,?>>
Parameters:
in - the stream to parse objects from
Returns:
a list containing those objects parsed from the input stream and their associated labels.

parseLine

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

Specified by:
parseLine in interface LinebasedParser<V extends NumberVector<?,?>>
Parameters:
line - single line
Returns:
parsing result

createDBObject

protected abstract V createDBObject(List<Double> attributes)

Creates a database object of type V.

Parameters:
attributes - the attributes of the vector to create.
Returns:
a RalVector of type V containing the given attribute values

Release 0.3 (2010-03-31_1612)