Examples of Assignments


Examples of edu.ucla.sspace.clustering.Assignments

                VectorMath.add(meanSenseVector, contexts.getRowVector(row));
            termToVector.put(term, meanSenseVector);
            return;
        }

        Assignments clusterAssignment =
            new ClutoClustering().cluster(contexts, numClusters,
                                          ClutoClustering.Method.AGGLOMERATIVE,
                                          ClutoClustering.Criterion.UPGMA);
       
        LOGGER.fine("Generative sense vectors for " + term);
       
        // For each of the clusters, compute the mean sense vector
        int[] clusterSize = new int[numClusters];

        // Use CompactSparseVector to conserve memory given the potentially
        // large number of sense vectors
        SparseDoubleVector[] meanSenseVectors =
            new CompactSparseVector[numClusters];

        for (int i = 0; i < meanSenseVectors.length; ++i)
            meanSenseVectors[i] = new CompactSparseVector(termToIndex.size());

        // For each of the contexts, determine which cluster it was in and sum
        // it value with the other contexts
        for (int row = 0; row < clusterAssignment.size(); ++row) {
            // Check whether this row was assigned a cluster
            if (clusterAssignment.get(row).assignments().length == 0)
                continue;               
            int assignment = clusterAssignment.get(row).assignments()[0];               
            clusterSize[assignment]++;

            DoubleVector contextVector = contexts.getRowVector(row);
            VectorMath.add(meanSenseVectors[assignment], contextVector);
        }
View Full Code Here

Examples of edu.ucla.sspace.clustering.Assignments

        // Convert the data points to a sparse matrix.
        SparseMatrix contexts = Matrices.asSparseMatrix(contextSet);

        // Cluster the context set.
        LOG.info("Clustering term: " + senseName);
        Assignments assignments = (numClusters > 0)
            ? clustering.cluster(contexts, numClusters, props)
            : clustering.cluster(contexts, props);
        LOG.info("Finished clustering term: " + senseName);

        SparseDoubleVector[] centroids = assignments.getSparseCentroids();

        // Add the centroids to the splitSenses map.
        for (int index = 0; index < centroids.length; ++index) {
            String sense = (index > 0)
                    ? senseName + "-" + index
                    : senseName;
            wordSpace.put(sense, centroids[index]);
        }

        LOG.info("Finished creating centroids for term: " + senseName);

        // Empty out the stored contexts to free up memory for later processes.
        contextSet.clear();

        // If the reporter is null, avoid making any report.
        if (reporter == null)
            return;

        // Generate the secondary context labels for each data point.
        String[] contextLabels = reporter.contextLabels(senseName);
        if (contextLabels.length == 0)
            return;

        LOG.info("Making assignment report: " + senseName);
        // Report the assignments for each clustered data point.  Note that some
        // data points might not have been clustered (Cluto based clustering
        // does this on occasion) so we must check for the number of assignments
        // first.
        for (int i = 0; i < assignments.size(); ++i)
            if (assignments.get(i).assignments().length > 0)
                reporter.updateAssignment(senseName, contextLabels[i],
                                          assignments.get(i).assignments()[0]);
        LOG.info("Finished making assignment report: " + senseName);
    }
View Full Code Here

Examples of edu.ucla.sspace.clustering.Assignments

            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++);
            System.out.printf("%s ", word);
            for (int i : assignment.assignments())
                System.out.printf("%d ", i);
            System.out.println();
        }
View Full Code Here

Examples of org.ggp.base.util.gdl.model.assignments.Assignments

    Map<SentenceForm, ? extends Collection<GdlSentence>> completedSentenceFormValues = allSentences.getSentences().asMap();

    for (GdlSentence chosenNewSentence : chosenNewSentences) {
      Map<GdlVariable, GdlConstant> preassignments = GdlUtils.getAssignmentMakingLeftIntoRight(chosenLiteral, chosenNewSentence);
      if (preassignments != null) {
        Assignments assignments = new AssignmentsImpl(preassignments, rule, varDomains, functionInfoMap, completedSentenceFormValues);
        AssignmentIterator asnItr = assignments.getIterator();
        while (asnItr.hasNext()) {
          Map<GdlVariable, GdlConstant> assignment = asnItr.next();

          boolean allSatisfied = true;
          for (GdlLiteral literal : rule.getBody()) {
View Full Code Here

Examples of org.ggp.base.util.gdl.model.assignments.Assignments

      for(GdlSentence alwaysTrueSentences : model.getSentencesListedAsTrue(curForm))
        trueFlowSentences.add(alwaysTrueSentences);
      for(GdlRule rule : model.getRules(curForm)) {
        GdlSentence head = rule.getHead();
        List<GdlVariable> varsInHead = GdlUtils.getVariables(head);
        Assignments assignments = AssignmentsFactory.getAssignmentsForRule(rule, model, functionInfoMap, Collections.EMPTY_MAP);

        AssignmentIterator asnItr = assignments.getIterator();
        while(asnItr.hasNext()) {
          Map<GdlVariable, GdlConstant> assignment = asnItr.next();
          boolean isGoodAssignment = true;

          GdlSentence transformedHead = CommonTransforms.replaceVariables(head, assignment);
View Full Code Here

Examples of org.ggp.base.util.gdl.model.assignments.Assignments

      return;
    }

    Map<GdlSentence, Set<Component>> inputsToOr = new HashMap<GdlSentence, Set<Component>>();
    for(GdlRule rule : rules) {
      Assignments assignments = AssignmentsFactory.getAssignmentsForRule(rule, model, functionInfoMap, completedSentenceFormValues);

      //Calculate vars in live (non-constant, non-distinct) conjuncts
      Set<GdlVariable> varsInLiveConjuncts = getVarsInLiveConjuncts(rule, constantChecker.getConstantSentenceForms());
      varsInLiveConjuncts.addAll(GdlUtils.getVariables(rule.getHead()));
      Set<GdlVariable> varsInRule = new HashSet<GdlVariable>(GdlUtils.getVariables(rule));
      boolean preventDuplicatesFromConstants =
        (varsInRule.size() > varsInLiveConjuncts.size());

      //Do we just pass those to the Assignments class in that case?
      for(AssignmentIterator asnItr = assignments.getIterator(); asnItr.hasNext(); ) {
        Map<GdlVariable, GdlConstant> assignment = asnItr.next();
        if(assignment == null) continue; //Not sure if this will ever happen

        ConcurrencyUtils.checkForInterruption();
View Full Code Here

Examples of org.junit.experimental.theories.internal.Assignments

                while (!parameterAssignment.isComplete()) {
                    List<PotentialAssignment> potentialAssignments = parameterAssignment.potentialsForNextUnassigned();
                    boolean isFirstSetOfArguments = listOfAssignments.isEmpty();
                    for (int i = 0; i < potentialAssignments.size(); i++) {
                        if (isFirstSetOfArguments) {
                            Assignments assignments = Assignments
                                .allUnassigned(fTestMethod.getMethod(), getTestClass());
                            listOfAssignments.add(assignments.assignNext(potentialAssignments.get(i)));
                        } else {
                            Assignments assignments = listOfAssignments.get(i);
                            try {
                                listOfAssignments.set(i, assignments.assignNext(potentialAssignments.get(i)));
                            } catch (IndexOutOfBoundsException e) {
                                listOfAssignments.add(assignments.assignNext(potentialAssignments.get(i)));
                            }
                        }

                    }
                    parameterAssignment = parameterAssignment.assignNext(null);
View Full Code Here

Examples of org.junit.experimental.theories.internal.Assignments

                while (!parameterAssignment.isComplete()) {
                    List<PotentialAssignment> potentialAssignments = parameterAssignment.potentialsForNextUnassigned();
                    boolean isFirstSetOfArguments = listOfAssignments.isEmpty();
                    for (int i = 0; i < potentialAssignments.size(); i++) {
                        if (isFirstSetOfArguments) {
                            Assignments assignments = Assignments
                                .allUnassigned(fTestMethod.getMethod(), getTestClass());
                            listOfAssignments.add(assignments.assignNext(potentialAssignments.get(i)));
                        } else {
                            Assignments assignments = listOfAssignments.get(i);
                            try {
                                listOfAssignments.set(i, assignments.assignNext(potentialAssignments.get(i)));
                            } catch (IndexOutOfBoundsException e) {
                                listOfAssignments.add(assignments.assignNext(potentialAssignments.get(i)));
                            }
                        }

                    }
                    parameterAssignment = parameterAssignment.assignNext(null);
View Full Code Here
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.