Exemple #1
0
		/// <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, in which
		/// case output instances should be collected after calling
		/// batchFinished(). If the input marks the start of a new batch, the
		/// output queue is cleared. This default implementation assumes all
		/// instance conversion will occur when batchFinished() is called.
		/// 
		/// </summary>
		/// <param name="instance">the input instance
		/// </param>
		/// <returns> true if the filtered instance may now be
		/// collected with output().
		/// </returns>
		/// <exception cref="NullPointerException">if the input format has not been
		/// defined.
		/// </exception>
		/// <exception cref="Exception">if the input instance was not of the correct 
		/// format or if there was a problem with the filtering.  
		/// </exception>
		public virtual bool input(Instance instance)
		{
			
			if (m_InputFormat == null)
			{
				throw new System.NullReferenceException("No input instance format defined");
			}
			if (m_NewBatch)
			{
				m_OutputQueue = new Queue();
				m_NewBatch = false;
			}
			bufferInput(instance);
			return false;
		}
Exemple #2
0
		/// <summary> Clears the output queue.</summary>
		protected internal virtual void  resetQueue()
		{
			
			m_OutputQueue = new Queue();
		}
Exemple #3
0
		/// <summary> Sets the format of the input instances. If the filter is able to
		/// determine the output format before seeing any input instances, it
		/// does so here. This default implementation clears the output format
		/// and output queue, and the new batch flag is set. Overriders should
		/// call <code>super.setInputFormat(Instances)</code>
		/// 
		/// </summary>
		/// <param name="instanceInfo">an Instances object containing the input instance
		/// structure (any instances contained in the object are ignored - only the
		/// structure is required).
		/// </param>
		/// <returns> true if the outputFormat may be collected immediately
		/// </returns>
		/// <exception cref="Exception">if the inputFormat can't be set successfully 
		/// </exception>
		public virtual bool setInputFormat(Instances instanceInfo)
		{
			
			m_InputFormat = instanceInfo.stringFreeStructure();
			m_InputStringAtts = getStringIndices(instanceInfo);
			m_OutputFormat = null;
			m_OutputQueue = new Queue();
			m_NewBatch = true;
			m_FirstBatchDone = false;
			return false;
		}
Exemple #4
0
		/// <summary> Sets the format of output instances. The derived class should use this
		/// method once it has determined the outputformat. The 
		/// output queue is cleared.
		/// 
		/// </summary>
		/// <param name="outputFormat">the new output format
		/// </param>
		protected internal virtual void  setOutputFormat(Instances outputFormat)
		{
			if (outputFormat != null)
			{
				m_OutputFormat = outputFormat.stringFreeStructure();
				m_OutputStringAtts = getStringIndices(m_OutputFormat);
				
				// Rename the attribute
				System.String relationName = outputFormat.relationName() + "-" + this.GetType().FullName;
				//			if (this instanceof OptionHandler) 
				//			{
				//				String [] options = ((OptionHandler)this).getOptions();
				//				for (int i = 0; i < options.length; i++) 
				//				{
				//					relationName += options[i].trim();
				//				}
				//			}
				m_OutputFormat.RelationName = relationName;
			}
			else
			{
				m_OutputFormat = null;
			}
			m_OutputQueue = new Queue();
		}