V
- the type of NumberVector usedpublic class NumberVectorLabelParser<V extends NumberVector<V,?>> extends AbstractStreamingParser
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.
Modifier and Type | Class and Description |
---|---|
static class |
NumberVectorLabelParser.Parameterizer<V extends NumberVector<V,?>>
Parameterization class.
|
BundleStreamSource.Event
Modifier and Type | Field and Description |
---|---|
protected LabelList |
curlbl
Current labels
|
protected V |
curvec
Current vector
|
protected int |
dimensionality
Dimensionality reported
|
static int |
DIMENSIONALITY_UNKNOWN
Constant used for unknown dimensionality (e.g. empty files)
|
static int |
DIMENSIONALITY_VARIABLE
Constant used for records of variable dimensionality (e.g. time series)
|
protected V |
factory
Vector factory class
|
static OptionID |
LABEL_INDICES_ID
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.
|
protected int |
lineNumber
Current line number
|
private static Logging |
logger
Logging class.
|
protected BundleMeta |
meta
Metadata
|
(package private) BundleStreamSource.Event |
nextevent
Event to report next
|
private BufferedReader |
reader
Buffer reader
|
static OptionID |
VECTOR_TYPE_ID
Parameter to specify the type of vectors to produce.
|
ATTRIBUTE_CONCATENATION, COLUMN_SEPARATOR_ID, COMMENT, NUMBER_PATTERN, QUOTE_CHAR, QUOTE_ID, quoteChar, WHITESPACE_PATTERN
Constructor and Description |
---|
NumberVectorLabelParser(Pattern colSep,
char quoteChar,
BitSet labelIndices,
V factory)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildMeta()
Update the meta element.
|
protected <A> V |
createDBObject(A attributes,
NumberArrayAdapter<?,A> adapter)
Creates a database object of type V.
|
Object |
data(int rnum)
Access a particular object and representation.
|
protected Logging |
getLogger()
Get the logger for this class.
|
BundleMeta |
getMeta()
Get the current meta data.
|
(package private) SimpleTypeInformation<V> |
getTypeInformation(int dimensionality)
Get a prototype object for the given dimensionality.
|
void |
initStream(InputStream in)
Init the streaming parser for the given input stream.
|
BundleStreamSource.Event |
nextEvent()
Get the next event
|
protected void |
parseLineInternal(String line)
Internal method for parsing a single line.
|
parse
tokenize, toString
private static final Logging logger
public static final OptionID LABEL_INDICES_ID
Key: -parser.labelIndices
public static final OptionID VECTOR_TYPE_ID
Key: -parser.vector-type
Default: DoubleVector
public static final int DIMENSIONALITY_UNKNOWN
public static final int DIMENSIONALITY_VARIABLE
protected BitSet labelIndices
protected V extends NumberVector<V,?> factory
private BufferedReader reader
protected int lineNumber
protected int dimensionality
protected BundleMeta meta
protected V extends NumberVector<V,?> curvec
protected LabelList curlbl
BundleStreamSource.Event nextevent
public void initStream(InputStream in)
StreamingParser
in
- the stream to parse objects frompublic BundleMeta getMeta()
BundleStreamSource
public BundleStreamSource.Event nextEvent()
BundleStreamSource
protected void buildMeta()
public Object data(int rnum)
BundleStreamSource
rnum
- Representation numberprotected void parseLineInternal(String line)
line
- Line to processprotected <A> V createDBObject(A attributes, NumberArrayAdapter<?,A> adapter)
Creates a database object of type V.
attributes
- the attributes of the vector to create.SimpleTypeInformation<V> getTypeInformation(int dimensionality)
dimensionality
- Dimensionalityprotected Logging getLogger()
AbstractParser
getLogger
in class AbstractParser