/** * 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. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been set. */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { push(instance); return true; } else { bufferInput(instance); return false; } }
if (getInputFormat() != null) { setInputFormat(getInputFormat());
/** * Signify that this batch of input to the filter is finished. Output() may * now be called to retrieve the filtered instances. * * @return true if there are instances pending output * @throws IllegalStateException if no input structure has been defined */ @Override public boolean batchFinished() { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } // Push instances for output into output queue Instances toFilter = getInputFormat(); int cutOff = (int) Math.round(toFilter.numInstances() * m_Percentage / 100); if (m_Inverse) { for (int i = 0; i < cutOff; i++) { push(toFilter.instance(i), false); // No need to copy } } else { for (int i = cutOff; i < toFilter.numInstances(); i++) { push(toFilter.instance(i), false); // No need to copy } } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }
if (getInputFormat() != null) { setInputFormat(getInputFormat());
/** * 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. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been set. */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { push(instance); return true; } else { bufferInput(instance); return false; } }
/** * Signify that this batch of input to the filter is finished. Output() may * now be called to retrieve the filtered instances. * * @return true if there are instances pending output * @throws IllegalStateException if no input structure has been defined */ @Override public boolean batchFinished() { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } // Push instances for output into output queue Instances toFilter = getInputFormat(); int cutOff = (int) Math.round(toFilter.numInstances() * m_Percentage / 100); if (m_Inverse) { for (int i = 0; i < cutOff; i++) { push(toFilter.instance(i), false); // No need to copy } } else { for (int i = cutOff; i < toFilter.numInstances(); i++) { push(toFilter.instance(i), false); // No need to copy } } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }