public boolean superSetInputFormat(M5Instances instanceInfo) throws Exception { m_InputFormat = instanceInfo.stringFreeStructure(); m_InputStringAtts = getStringIndices(instanceInfo); m_OutputFormat = null; m_OutputQueue = new Queue(); m_NewBatch = true; return false; }
/** * This will remove all buffered instances from the inputformat dataset. Use this method rather * than getInputFormat().delete(); */ protected void flushInput() { if (m_InputStringAtts.length > 0) { m_InputFormat = m_InputFormat.stringFreeStructure(); } else { // This more efficient than new Instances(m_InputFormat, 0); m_InputFormat.delete(); } }
/** * Output an instance after filtering and remove from the output queue. * * @return the instance that has most recently been filtered (or null if the queue is empty). * @exception NullPointerException if no output structure has been defined */ public M5Instance output() { if (m_OutputFormat == null) { throw new NullPointerException("No output instance format defined"); } if (m_OutputQueue.empty()) { return null; } M5Instance result = (M5Instance) m_OutputQueue.pop(); // Clear out references to old strings occasionally if (m_OutputQueue.empty() && m_NewBatch) { if (m_OutputStringAtts.length > 0) { m_OutputFormat = m_OutputFormat.stringFreeStructure(); } } return result; }
/** * Sets the format of output instances. The derived class should use this method once it has * determined the outputformat. The output queue is cleared. * * @param outputFormat the new output format */ protected void setOutputFormat(M5Instances outputFormat) { if (outputFormat != null) { m_OutputFormat = outputFormat.stringFreeStructure(); m_OutputStringAtts = getStringIndices(m_OutputFormat); // Rename the attribute String relationName = outputFormat.relationName() + "-" + this.getClass().getName(); if (this instanceof NominalToBinaryFilter) { String[] options = ((NominalToBinaryFilter) this).getOptions(); for (int i = 0; i < options.length; i++) { relationName += options[i].trim(); } } m_OutputFormat.setRelationName(relationName); } else { m_OutputFormat = null; } m_OutputQueue = new Queue(); }