/** * Signify that this batch of input to the filter is finished. * * @return true if there are instances pending output * @throws NullPointerException if no input structure has been defined, * @throws Exception if there was a problem finishing the batch. */ @Override public boolean batchFinished() throws Exception { int i; Instances insts; Instance inst; if (getInputFormat() == null) { throw new NullPointerException("No input instance format defined"); } insts = getInputFormat(); if (!isFirstBatchDone()) { setup(insts); } for (i = 0; i < insts.numInstances(); i++) { inst = convertInstance(insts.instance(i)); inst.setDataset(getOutputFormat()); push(inst, false); // No need to copy } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }
/** * Signify that this batch of input to the filter is finished. * * @return true if there are instances pending output * @throws NullPointerException if no input structure has been defined, * @throws Exception if there was a problem finishing the batch. */ @Override public boolean batchFinished() throws Exception { int i; Instances insts; Instance inst; if (getInputFormat() == null) { throw new NullPointerException("No input instance format defined"); } insts = getInputFormat(); if (!isFirstBatchDone()) { setup(insts); } for (i = 0; i < insts.numInstances(); i++) { inst = convertInstance(insts.instance(i)); inst.setDataset(getOutputFormat()); push(inst, false); // No need to copy } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }
/** * Input an instance for filtering. Filter requires all training 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 * @throws Exception if conversion fails */ @Override public boolean input(Instance instance) throws Exception { Instance inst; if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (isNewBatch()) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { inst = convertInstance(instance); inst.setDataset(getOutputFormat()); push(inst, false); // No need to copy return true; } else { bufferInput(instance); return false; } }
/** * Input an instance for filtering. Filter requires all training 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 * @throws Exception if conversion fails */ @Override public boolean input(Instance instance) throws Exception { Instance inst; if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (isNewBatch()) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { inst = convertInstance(instance); inst.setDataset(getOutputFormat()); push(inst, false); // No need to copy return true; } else { bufferInput(instance); return false; } }