Package edu.ucla.sspace.mains

Source Code of edu.ucla.sspace.mains.VsmMain

/*
* Copyright 2010 David Jurgens
*
* This file is part of the S-Space package and is covered under the terms and
* conditions therein.
*
* The S-Space package is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation and distributed hereunder to you.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND NO REPRESENTATIONS OR WARRANTIES,
* EXPRESS OR IMPLIED ARE MADE.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, WE MAKE
* NO REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY
* PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE OR DOCUMENTATION
* WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER
* RIGHTS.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package edu.ucla.sspace.mains;

import edu.ucla.sspace.common.ArgOptions;
import edu.ucla.sspace.common.SemanticSpace;
import edu.ucla.sspace.common.SemanticSpaceIO.SSpaceFormat;

import edu.ucla.sspace.vsm.VectorSpaceModel;

import java.io.IOError;
import java.io.IOException;

import java.util.Properties;

/**
* An executable class for running {@link VectorSpaceModel} (VSM) from the
* command line.  See the <a
* href="http://code.google.com/p/airhead-research/wiki/VectorSpaceModel"> wiki
* page</a> for details on running this class from the command line. <p>
*
* This class is desgined to run multi-threaded and performs well with one
* thread per core, which is the default setting.
*
* @see VectorSpaceMdeol
* @see edu.ucla.sspace.matrix.Transform Transform
*
* @author David Jurgens
*/
public class VsmMain extends GenericMain {

    private VsmMain() { }

    /**
     * Adds all of the options to the {@link ArgOptions}.
     */
    protected void addExtraOptions(ArgOptions options) {
        options.addOption('T', "transform", "a MatrixTransform class to "
                          + "use for preprocessing", true, "CLASSNAME",
                          "Algorithm Options");
    }

    public static void main(String[] args) {
        VsmMain vsm = new VsmMain();
        try {
            vsm.run(args);
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
    }
   
    /**
     * {@inheritDoc}
     */
    protected SemanticSpace getSpace() {
        try {
            return new VectorSpaceModel();
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
    }

    /**
     * Returns the {@likn SSpaceFormat.SPARSE_BINARY binary} format as the
     * default format of a {@code VectorSpaceModel} space.
     */
    protected SSpaceFormat getSpaceFormat() {
        return SSpaceFormat.SPARSE_BINARY;
    }

    /**
     * {@inheritDoc}
     */
    protected Properties setupProperties() {
        // use the System properties in case the user specified them as
        // -Dprop=<val> to the JVM directly.
        Properties props = System.getProperties();

        if (argOptions.hasOption("transform")) {
            props.setProperty(VectorSpaceModel.MATRIX_TRANSFORM_PROPERTY,
                              argOptions.getStringOption("transform"));
        }

        return props;
    }
}
TOP

Related Classes of edu.ucla.sspace.mains.VsmMain

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.