V
- vector type@Title(value="Sparse 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.") public class SparseNumberVectorLabelParser<V extends SparseNumberVector<?>> extends NumberVectorLabelParser<V>
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
each, where index is the number of
the corresponding dimension, and value is the value of the corresponding
attribute. A complet line then could look like this:
3 7 12.34 8 56.78 11 1.234 objectlabelwhere
3
indicates there are three attributes set,
7,8,11
are the attributes indexes and there is a non-numerical
object label.
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.
Modifier and Type | Class and Description |
---|---|
static class |
SparseNumberVectorLabelParser.Parameterizer<V extends SparseNumberVector<?>>
Parameterization class.
|
BundleStreamSource.Event
Modifier and Type | Field and Description |
---|---|
(package private) ArrayList<String> |
labels
(Reused) label buffer.
|
private static Logging |
LOG
Class logger.
|
private SparseNumberVector.Factory<V,?> |
sparsefactory
Same as
NumberVectorLabelParser.factory , but subtype. |
(package private) gnu.trove.map.hash.TIntDoubleHashMap |
values
(Reused) set of values for the number vector.
|
attributes, columnnames, curlbl, curvec, factory, haslabels, labelcolumns, labelIndices, lineNumber, maxdim, meta, mindim, nextevent, unique
ATTRIBUTE_CONCATENATION, comment, COMMENT_PATTERN, DEFAULT_SEPARATOR, NUMBER_PATTERN, QUOTE_CHARS, tokenizer
Constructor and Description |
---|
SparseNumberVectorLabelParser(Pattern colSep,
String quoteChars,
Pattern comment,
BitSet labelIndices,
SparseNumberVector.Factory<V,?> factory)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Logging |
getLogger()
Get the logger for this class.
|
protected SimpleTypeInformation<V> |
getTypeInformation(int mindim,
int maxdim)
Get a prototype object for the given dimensionality.
|
protected void |
parseLineInternal(String line)
Internal method for parsing a single line.
|
buildMeta, createDBObject, data, getMeta, initStream, nextEvent
parse
lengthWithoutLinefeed, toString
private static final Logging LOG
private SparseNumberVector.Factory<V extends SparseNumberVector<?>,?> sparsefactory
NumberVectorLabelParser.factory
, but subtype.gnu.trove.map.hash.TIntDoubleHashMap values
public SparseNumberVectorLabelParser(Pattern colSep, String quoteChars, Pattern comment, BitSet labelIndices, SparseNumberVector.Factory<V,?> factory)
colSep
- Column separatorquoteChars
- Quotation charactercomment
- Comment patternlabelIndices
- Indices to use as labelsfactory
- Vector factoryprotected void parseLineInternal(String line)
NumberVectorLabelParser
parseLineInternal
in class NumberVectorLabelParser<V extends SparseNumberVector<?>>
line
- Line to processprotected SimpleTypeInformation<V> getTypeInformation(int mindim, int maxdim)
NumberVectorLabelParser
getTypeInformation
in class NumberVectorLabelParser<V extends SparseNumberVector<?>>
mindim
- Minimum dimensionalitymaxdim
- Maximum dimensionalityprotected Logging getLogger()
AbstractParser
getLogger
in class NumberVectorLabelParser<V extends SparseNumberVector<?>>