⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miningfilterstream.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

 /**
  * Title: XELOPES Data Mining Library
  * Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
  * Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
  * Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
  * @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
  * @version 1.0
  */

package com.prudsys.pdm.Input;

import java.util.Enumeration;
import java.util.Vector;

import com.prudsys.pdm.Core.MiningDataSpecification;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Transform.MiningTransformationActivity;
import com.prudsys.pdm.Transform.MiningTransformationStep;
import com.prudsys.pdm.Transform.MiningTransformer;

/**
 * A <code>MiningFilterStream</code> contains
 * some other mining input stream, which it uses as
 * its  basic source of data, possibly transforming
 * the data along the way or providing  additional
 * functionality. The class <code>MiningFilterStream</code>
 * itself simply overrides all  methods of
 * <code>MiningInputStream</code> with versions that
 * pass all requests to the contained  input
 * stream. Subclasses of <code>MiningFilterStream</code>
 * may further override some of these methods
 * and may also provide additional methods
 * and fields.
 */
public class MiningFilterStream extends MiningInputStream
{
    // -----------------------------------------------------------------------
    //  Variables declarations
    // -----------------------------------------------------------------------
    /** Initial mining input stream. */
    protected MiningInputStream miningInputStream;

    /** Transformation object applied to initial stream. */
    protected MiningTransformer miningTransformer;

    // -----------------------------------------------------------------------
    //  Constructor
    // -----------------------------------------------------------------------
    /**
     * Constructs mining filter stream from an mining input
     * stream and a mining transformer.
     *
     * @param miningInputStream mining input stream for applying the filter
     * @param miningTransformer mining transformer
     */
    public MiningFilterStream(MiningInputStream miningInputStream, MiningTransformer miningTransformer )
    {
        this.miningInputStream = miningInputStream;
        this.miningTransformer = miningTransformer;
    }

    // -----------------------------------------------------------------------
    //  Getter and setter methods
    // -----------------------------------------------------------------------
    /**
     * Returns supported stream methods.  Taken from the passed input stream;
     * if there are update methods they are removed.
     *
     * @return supported stream methods
     */
    public Enumeration getSupportedStreamMethods() {

      Enumeration suppinp = miningInputStream.getSupportedStreamMethods();

      Vector suppmeth = new Vector();
      while ( suppinp.hasMoreElements() ) {
        String meth = (String) suppinp.nextElement();
        if ( meth.equals("updateSetMetaData") || meth.equals("updateRemoveAllVector") ||
             meth.equals("updateAppendVector") )
          continue;
        suppmeth.addElement(meth);
      }

      return suppmeth.elements();
    }

    /**
     * Returns physical filter model. This is the same model
     * as that of the mining input stream.
     *
     * @return physical model in terms of CWM
     * @exception MiningException couldn't access phsyical model
     */
     public org.omg.cwm.objectmodel.core.Package getPhysicalModel() {

       return miningInputStream.getPhysicalModel();
     }

     /**
      * Determines physical model and writes it to variable physicalModel.
      * Calls the same method of the mining input stream.
      *
      * @throws MiningException error while determening physical model
      */
     public void findPhysicalModel() throws MiningException {

       miningInputStream.findPhysicalModel();
     }

     /**
      * Returns the CWM mapping from the physical to the logical data model.
      *
      * @return transformation of physical to logical data model
      * @throws MiningException couldn't get transformation
      */
     public org.omg.cwm.analysis.transformation.TransformationMap getPhysicalToLogicalModelTransformation()
         throws MiningException {

       return miningInputStream.getPhysicalToLogicalModelTransformation();
     }

    /**
     * Returns meta data of mining input stream. Therefore, the
     * getMetaData method of the mining input stream is used and
     * subsequentially the transform method is applied to the
     * result.
     *
     * @return transformed meta data
     * @exception MiningException if a mining source access error occurs
     */
    public MiningDataSpecification getMetaData() throws MiningException
    {
        if( miningTransformer != null )
        {
            if( metaData == null )
            {
                // Transform meta data:
                metaData = miningTransformer.transform( miningInputStream.getMetaData() );

                // Initializations if this is the first transformation ever:
                if (! metaData.isTransformed()) {
                  metaData.setPretransformedMetaData( miningInputStream.getMetaData() );
                  metaData.setMiningTransformationActivity( new MiningTransformationActivity() );
                  metaData.setTransformed( true );
                };

                // Add mining transformer to meta data transformation history:
                if (miningTransformer instanceof MiningTransformationStep)
                  metaData.getMiningTransformationActivity().addTransformationStep( (MiningTransformationStep) miningTransformer );
                if (miningTransformer instanceof MiningTransformationActivity)
                  metaData.getMiningTransformationActivity().addTransformationActivity( (MiningTransformationActivity) miningTransformer );
            };
        }
        else
        {
            metaData = miningInputStream.getMetaData();
        };

        return metaData;
    }

    // -----------------------------------------------------------------------
    //  General stream methods
    // -----------------------------------------------------------------------
    /**
     * Opens mining filter stream.
     *
     * @exception MiningException if a mining source access error occurs
     */
    public void open() throws MiningException
    {
      miningInputStream.open();
    }

    /**
     * Closes mining filter stream.
     *
     * @exception MiningException if a mining source access error occurs
     */
    public void close() throws MiningException
    {
        miningInputStream.close();
    }

    /**
     * Determines meta data of stream. Should be used carefully because
     * simply transforms recognized meta data from passed input stream.
     * However, in general there is no guarantee that this meta data
     * is suitable for the transformer.
     *
     * @return meta data of stream
     * @throws MiningException if a mining source access error occurs
     */
    public MiningDataSpecification recognize() throws MiningException
    {
        if (miningTransformer != null)
          return miningTransformer.transform( miningInputStream.recognize() );
        else
          return miningInputStream.recognize();
    }

    // -----------------------------------------------------------------------
    //  Methods of cursor positioning
    // -----------------------------------------------------------------------
    /**
     * Reset cursor using the reset method of the mining input stream.
     *
     * @exception MiningException if a mining source access error occurs
     */
    public void reset() throws MiningException
    {
        miningInputStream.reset();
    }

    /**
     * Advances cursor position using the next method of mining input
     * stream.
     *
     * @return true if there is a further vector to read, elso false
     * @exception MiningException if a mining source access error occurs
     */
    public boolean next() throws MiningException
    {
        return miningInputStream.next();
    }

    /**
     * Move cursor using to specified position using the move
     * method of the mining input stream.
     *
     * @param position new position of the cursor
     * @return true if cursor could be positioned, false if not
     * @exception MiningException if a mining source access error occurs
     */
    public boolean move(int position) throws MiningException
    {
        return miningInputStream.move( position );
    }

    // -----------------------------------------------------------------------
    //  Methods of reading from the stream
    // -----------------------------------------------------------------------
    /**
     * Read mining vector at current cursor position.
     * For doing this, the read method of the mining input stream is
     * used and then the transform method of the MiningTransformer
     * applied to the vector read.
     *
     * @return transformed mining vector at current cursor position
     * @exception MiningException if a mining source access error occurs
     */
    public MiningVector read() throws MiningException
    {
        MiningVector vector = miningInputStream.read();
        if( miningTransformer != null )
        {
            MiningVector transformedVector = miningTransformer.transform( vector );
            transformedVector.setMetaData( getMetaData() );
            return transformedVector;
        }
        else
        {
            return vector;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -