push(new SparseInstance(instance.weight(), values, indices, outputFormatPeek().numAttributes()));
Instance inst = new SparseInstance(instance.weight(), values, indices, outputFormatPeek().numAttributes()); inst.setDataset(outputFormatPeek()); push(inst);
  private void convertInstance(Instance instance) throws Exception {    // Convert the instance into a sorted set of indexes    TreeMap contained = new TreeMap();    for (int j = 0; j < instance.numAttributes(); j++) {       if ((getInputFormat().attribute(j).type() == Attribute.STRING)           && (instance.isMissing(j) == false)) {        StringTokenizer st = new StringTokenizer(instance.stringValue(j),                                                 DELIMS);        while (st.hasMoreTokens()) {          String word = st.nextToken();          Integer index = (Integer) m_Dictionary.get(word);          if (index != null) {            contained.put(index, new Double(1));          }        }      }    }    int firstCopy = m_Dictionary.size();    for (int i = 0; i < getInputFormat().numAttributes(); i++) {      if (getInputFormat().attribute(i).type() != Attribute.STRING) {        if (instance.value(i) != 0.0) {          contained.put(new Integer(firstCopy++),                         new Double(instance.value(i)));        }      }         }        // Convert the set to structures needed to create a sparse instance.    double [] values = new double [contained.size()];    int [] indices = new int [contained.size()];    Iterator it = contained.keySet().iterator();    for (int i = 0; it.hasNext(); i++) {      Integer index = (Integer)it.next();      Double value = (Double)contained.get(index);      values[i] = value.doubleValue();      indices[i] = index.intValue();    }    push(new SparseInstance(instance.weight(), values, indices,                             outputFormatPeek().numAttributes()));    //System.err.print("#"); System.err.flush();  }