extends AbstractStreamingParser.Parameterizer {
/**
* 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: {@code -parser.labelIndices}
*
*/
public static final OptionID LABEL_INDICES_ID = new OptionID("parser.labelIndices", "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.");
/**
* Parameter to specify the type of vectors to produce.
*
* Key: {@code -parser.vector-type}
* Default: DoubleVector
*
*/
public static final OptionID VECTOR_TYPE_ID = new OptionID("parser.vector-type", "The type of vectors to create for numerical attributes.");
/**
* Keeps the indices of the attributes to be treated as a string label.
*/
protected long[] labelIndices;
/**
* Factory object.
*/
protected NumberVector.Factory factory;
@Override
protected void makeOptions(Parameterization config) {
super.makeOptions(config);
getLabelIndices(config);
getFactory(config);
}
/**
* Get the object factory.
*
* @param config Parameterization
*/
protected void getFactory(Parameterization config) {
ObjectParameter> factoryP = new ObjectParameter<>(VECTOR_TYPE_ID, NumberVector.Factory.class, DoubleVector.Factory.class);
if(config.grab(factoryP)) {
factory = factoryP.instantiateClass(config);
}
}
/**
* Get the label indices.
*
* @param config Parameterization
*/
protected void getLabelIndices(Parameterization config) {
IntListParameter labelIndicesP = new IntListParameter(LABEL_INDICES_ID, true);
if(config.grab(labelIndicesP)) {
labelIndices = labelIndicesP.getValueAsBitSet();
}
}
@Override
protected NumberVectorLabelParser makeInstance() {
return new NumberVectorLabelParser<>(format, labelIndices, factory);
}
}
}