String relationName;
if (m_sourceFile != null)
relationName = (m_sourceFile.getName()).replaceAll("\\.[cC][sS][vV]$","");
else
relationName = "stream";
Instances dataSet = new Instances(relationName,
atts,
m_cumulativeInstances.size());
for (int i = 0; i < m_cumulativeInstances.size(); i++) {
current = m_cumulativeInstances.get(i);
double [] vals = new double[dataSet.numAttributes()];
for (int j = 0; j < current.size(); j++) {
Object cval = current.get(j);
if (cval instanceof String) {
if (((String)cval).compareTo(m_MissingValue) == 0) {
vals[j] = Utils.missingValue();
} else {
if (dataSet.attribute(j).isString()) {
vals[j] = dataSet.attribute(j).addStringValue((String) cval);
}
else if (dataSet.attribute(j).isNominal()) {
// find correct index
Hashtable<Object,Integer> lookup = m_cumulativeStructure.get(j);
int index = ((Integer)lookup.get(cval)).intValue();
vals[j] = index;
}
else {
throw new IllegalStateException("Wrong attribute type at position " + (i+1) + "!!!");
}
}
} else if (dataSet.attribute(j).isNominal()) {
// find correct index
Hashtable<Object,Integer> lookup = m_cumulativeStructure.get(j);
int index = ((Integer)lookup.get(cval)).intValue();
vals[j] = index;
} else if (dataSet.attribute(j).isString()) {
vals[j] = dataSet.attribute(j).addStringValue("" + cval);
} else {
vals[j] = ((Double)cval).doubleValue();
}
}
dataSet.add(new DenseInstance(1.0, vals));
}
m_structure = new Instances(dataSet, 0);
setRetrieval(BATCH);
m_cumulativeStructure = null; // conserve memory
// close the stream
m_sourceReader.close();