/// <summary> Input an instance for filtering. Ordinarily the instance is processed /// and made available for output immediately. Some filters require all /// instances be read before producing output. /// /// </summary> /// <param name="instance">the input instance /// </param> /// <returns> true if the filtered instance may now be /// collected with output(). /// </returns> /// <exception cref="IllegalStateException">if no input structure has been defined. /// </exception> public override bool input(Instance instance) { if (getInputFormat() == null) { throw new System.SystemException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (getOutputFormat().numAttributes() == 0) { return false; } double[] vals = new double[getOutputFormat().numAttributes()]; for (int i = 0; i < m_SelectedAttributes.Length; i++) { int current = m_SelectedAttributes[i]; vals[i] = instance.value_Renamed(current); } Instance inst = null; if (instance is SparseInstance) { inst = new SparseInstance(instance.weight(), vals); } else { inst = new Instance(instance.weight(), vals); } copyStringValues(inst, false, instance.dataset(), m_InputStringIndex, getOutputFormat(), OutputStringIndex); inst.Dataset = getOutputFormat(); push(inst); return true; }