de.lmu.ifi.dbs.elki.parser
Class SparseFloatVectorLabelParser
java.lang.Object
de.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.parser.AbstractParser<V>
de.lmu.ifi.dbs.elki.parser.NumberVectorLabelParser<SparseFloatVector>
de.lmu.ifi.dbs.elki.parser.SparseFloatVectorLabelParser
- All Implemented Interfaces:
- LinebasedParser<SparseFloatVector>, Parser<SparseFloatVector>, Parameterizable
@Title(value="Sparse Float Vector Label Parser")
@Description(value="Parser for the following line format:\nA single line provides a single point. Entries are separated by whitespace. The values will be parsed as floats (resulting in a set of SparseFloatVectors). 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.Any pair of two subsequent substrings not containing whitespace is tried to be read as int and float. If this fails for the first of the pair (interpreted ans index), it will be appended to a label. (Thus, any label must not be parseable as Integer.) If the float component is not parseable, an exception will be thrown. Empty lines and lines beginning with \"#\" will be ignored. Having the file parsed completely, the maximum occuring dimensionality is set as dimensionality to all created SparseFloatvectors.")
public class SparseFloatVectorLabelParser
- extends NumberVectorLabelParser<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. |
dimensionality
private int dimensionality
- Holds the dimensionality of the parsed data which is the maximum occurring
index of any attribute.
SparseFloatVectorLabelParser
public SparseFloatVectorLabelParser(Parameterization config)
- Constructor, adhering to
Parameterizable
- Parameters:
config
- Parameterization
createDBObject
public SparseFloatVector createDBObject(List<Double> attributes)
- Creates a DoubleVector out of the given attribute values.
- Specified by:
createDBObject
in class NumberVectorLabelParser<SparseFloatVector>
- Parameters:
attributes
- the attributes of the vector to create.
- Returns:
- a RalVector of type V containing the given attribute values
- See Also:
NumberVectorLabelParser.createDBObject(java.util.List)
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 NumberVectorLabelParser<SparseFloatVector>
- Parameters:
line
- single line
- Returns:
- parsing result
- See Also:
NumberVectorLabelParser.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 NumberVectorLabelParser<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:
NumberVectorLabelParser.parse(java.io.InputStream)