Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.parser
Class RealVectorLabelParser<V extends RealVector<V,?>>

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<V>
Type Parameters:
V - the type of RealVector expected in the ParsingResult
All Implemented Interfaces:
Loggable, Parser<V>, Parameterizable
Direct Known Subclasses:
RealVectorLabelTransposingParser

public class RealVectorLabelParser<V extends RealVector<V,?>>
extends AbstractParser<V>

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

The parser provides a parameter for parsing the real values as doubles (default) (resulting in a ParsingResult of DoubleVectors) or float (resulting in a ParsingResult of FloatVectors).

Several labels may be given per point. A label must not be parseable as double (or float). 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
static String CLASS_LABEL_INDEX_D
          Description for the parameter numerical class label.
static String CLASS_LABEL_INDEX_P
          The parameter name for an index of a numerical class label.
static IntParameter CLASS_LABEL_INDEX_PARAM
          The parameter for an index of a numerical class label.
private  int classLabelIndex
          Keeps the index of an attribute to be treated as a string label.
static String FLOAT_D
          Description for parameter float.
static String FLOAT_F
          Option string for parameter float.
protected  boolean parseFloat
          If true, the real values are parsed as floats.
 
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
 
Constructor Summary
RealVectorLabelParser()
          Provides a parser for parsing one point per line, attributes separated by whitespace.
 
Method Summary
 String description()
          Returns a description of the class and the required parameters.
 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.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
toString, usage
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, checkGlobalParameterConstraints, deleteOption, description, description, getAttributeSettings, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, 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, getAttributeSettings, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

FLOAT_F

public static final String FLOAT_F
Option string for parameter float.

See Also:
Constant Field Values

FLOAT_D

public static final String FLOAT_D
Description for parameter float.

See Also:
Constant Field Values

parseFloat

protected boolean parseFloat
If true, the real values are parsed as floats.


CLASS_LABEL_INDEX_P

public static final String CLASS_LABEL_INDEX_P
The parameter name for an index of a numerical class label.

See Also:
Constant Field Values

CLASS_LABEL_INDEX_D

public static final String CLASS_LABEL_INDEX_D
Description for the parameter numerical class label.


CLASS_LABEL_INDEX_PARAM

public static final IntParameter CLASS_LABEL_INDEX_PARAM
The parameter for an index of a numerical class label. The corresponding numerical value is treated as string label an can be selected as class label by the AbstractDatabaseConnection. A non-numerical class label can be directly selected from the labels after parsing via the corresponding parameter of the AbstractDatabaseConnection: CLASS_LABEL_INDEX_P.

The parameter is optional and the default value is set to -1.


classLabelIndex

private int classLabelIndex
Keeps the index of an attribute to be treated as a string label.

Constructor Detail

RealVectorLabelParser

public RealVectorLabelParser()
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 (or float). Lines starting with "#" will be ignored.

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.

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:
Parser.parse(java.io.InputStream)

description

public String description()
Description copied from interface: Parameterizable
Returns a description of the class and the required parameters.

This description should be suitable for a usage description as for a standalone application.

Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.description()

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

Release 0.1 (2008-07-10_1838)