Package edu.ucla.sspace.clustering

Examples of edu.ucla.sspace.clustering.Clustering


            return new StreamingWordsi(getAcceptedWords(), getExtractor(),
                                       clusterGenerator, reporter, numClusters);
        } else if (options.hasOption('b')) {
            // Create a WaitingWordsi instance that uses the specified batch
            // clustering implementation.
            Clustering clustering =
                ReflectionUtil.getObjectInstance(options.getStringOption('b'));
            return new WaitingWordsi(getAcceptedWords(), getExtractor(),
                                     clustering, reporter, numClusters);
        } else {
            // None of the required options was provided, report an error and
View Full Code Here


            System.out.println("Usage: ClusterSSpace\n" +
                               options.prettyPrint());
            System.exit(1);
        }

        Clustering clustering = ReflectionUtil.getObjectInstance(
                options.getStringOption('a'));
        SemanticSpace sspace = new StaticSemanticSpace(
                options.getStringOption('s'));
        int numClusters = options.getIntOption('c', 0);

        Set<String> words = sspace.getWords();
        List<DoubleVector> vectors = new ArrayList<DoubleVector>();
        List<SparseDoubleVector> sparseVectors =
            new ArrayList<SparseDoubleVector>();
        for (String word : words) {
            Vector v = sspace.getVector(word);
            if (v instanceof SparseDoubleVector)
                sparseVectors.add((SparseDoubleVector) v);
            else
                vectors.add(Vectors.asDouble(sspace.getVector(word)));
        }

        Properties props = System.getProperties();
        Assignments assignments = null;
        if (sparseVectors.size() > 0) {
            SparseMatrix matrix = Matrices.asSparseMatrix(sparseVectors);
            assignments = (numClusters > 0)
                ? clustering.cluster(matrix, numClusters, props)
                : clustering.cluster(matrix, props);
        } else {
            Matrix matrix = Matrices.asMatrix(vectors);
            assignments = (numClusters > 0)
                ? clustering.cluster(matrix, numClusters, props)
                : clustering.cluster(matrix, props);
        }

        int a = 0;
        for (String word : words) {
            Assignment assignment = assignments.get(a++);
View Full Code Here

TOP

Related Classes of edu.ucla.sspace.clustering.Clustering

Copyright © 2018 www.massapicom. 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.