Example usage for com.google.common.collect Multiset size

List of usage examples for com.google.common.collect Multiset size

Introduction

In this page you can find the example usage for com.google.common.collect Multiset size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this collection.

Usage

From source file:sklearn.cluster.KMeans.java

@Override
public ClusteringModel encodeModel(Schema schema) {
    int[] shape = getClusterCentersShape();

    int numberOfClusters = shape[0];
    int numberOfFeatures = shape[1];

    List<? extends Number> clusterCenters = getClusterCenters();
    List<Integer> labels = getLabels();

    Multiset<Integer> labelCounts = HashMultiset.create();

    if (labels != null) {
        labelCounts.addAll(labels);//from w  w w  . jav a2  s.  co m
    }

    List<Cluster> clusters = new ArrayList<>();

    for (int i = 0; i < numberOfClusters; i++) {
        Array array = PMMLUtil
                .createRealArray(MatrixUtil.getRow(clusterCenters, numberOfClusters, numberOfFeatures, i));

        Cluster cluster = new Cluster().setId(String.valueOf(i))
                .setSize((labelCounts.size() > 0 ? labelCounts.count(i) : null)).setArray(array);

        clusters.add(cluster);
    }

    List<Feature> features = schema.getFeatures();

    List<ClusteringField> clusteringFields = ClusteringModelUtil.createClusteringFields(features);

    ComparisonMeasure comparisonMeasure = new ComparisonMeasure(ComparisonMeasure.Kind.DISTANCE)
            .setCompareFunction(CompareFunction.ABS_DIFF).setMeasure(new SquaredEuclidean());

    Output output = ClusteringModelUtil.createOutput(FieldName.create("Cluster"), clusters);

    ClusteringModel clusteringModel = new ClusteringModel(MiningFunction.CLUSTERING,
            ClusteringModel.ModelClass.CENTER_BASED, numberOfClusters, ModelUtil.createMiningSchema(schema),
            comparisonMeasure, clusteringFields, clusters).setOutput(output);

    return clusteringModel;
}

From source file:it.units.malelab.ege.distributed.master.UIRunnable.java

private void printJobs(TextGraphics g, int x0, int y0, int w, int h) {
    //count jobs/*from  w  w  w. j a  v  a2  s.  co  m*/
    int nToDoJobs = 0;
    int nOngoingJobs = 0;
    int nDoneJobs = 0;
    synchronized (master.getJobs()) {
        for (JobInfo jobInfo : master.getJobs().values()) {
            if (jobInfo.getStatus().equals(JobInfo.Status.TO_DO)) {
                nToDoJobs = nToDoJobs + 1;
            } else if (jobInfo.getStatus().equals(JobInfo.Status.ONGOING)) {
                nOngoingJobs = nOngoingJobs + 1;
            } else if (jobInfo.getStatus().equals(JobInfo.Status.DONE)) {
                nDoneJobs = nDoneJobs + 1;
            }
        }
    }
    //print job info
    g.setForegroundColor(TextColor.ANSI.WHITE);
    putString(g, 0, 0, x0, y0, w, h, String.format("All/todo/running/done: %3d/%3d/%3d/%3d",
            master.getJobs().size(), nToDoJobs, nOngoingJobs, nDoneJobs));
    Map<String, Map<Object, Multiset<JobInfo.Status>>> allKeyCounts = new TreeMap<>();
    synchronized (master.getJobs()) {
        for (JobInfo jobInfo : master.getJobs().values()) {
            for (Map.Entry<String, Object> jobKeyEntry : ((Map<String, Object>) jobInfo.getJob().getKeys())
                    .entrySet()) {
                inc(jobKeyEntry.getKey(), jobKeyEntry.getValue(), jobInfo.getStatus(), allKeyCounts);
            }
        }
    }
    int y = 2;
    for (String keyName : allKeyCounts.keySet()) {
        g.setForegroundColor(TextColor.ANSI.WHITE);
        putString(g, 0, y, x0, y0, w, h, keyName + ":");
        y = y + 1;
        int x = 2;
        for (Object keyValue : allKeyCounts.get(keyName).keySet()) {
            Multiset<JobInfo.Status> statuses = allKeyCounts.get(keyName).get(keyValue);
            double completionRate = (double) statuses.count(JobInfo.Status.DONE) / (double) (statuses.size());
            if (x >= w - 1) {
                x = 2;
                y = y + 1;
            }
            if (completionRate == 1) {
                g.setForegroundColor(TextColor.ANSI.GREEN);
            } else if (statuses.count(JobInfo.Status.ONGOING) > 0) {
                g.setForegroundColor(TextColor.ANSI.YELLOW);
            } else {
                g.setForegroundColor(TextColor.ANSI.RED);
            }
            if (completionRate == 0) {
                putString(g, x, y, x0, y0, w, h, "-");
            } else if (completionRate < .25) {
                putString(g, x, y, x0, y0, w, h, "" + Symbols.BLOCK_SPARSE);
            } else if (completionRate < .50) {
                putString(g, x, y, x0, y0, w, h, "" + Symbols.BLOCK_MIDDLE);
            } else if (completionRate < .75) {
                putString(g, x, y, x0, y0, w, h, "" + Symbols.BLOCK_DENSE);
            } else {
                putString(g, x, y, x0, y0, w, h, "" + Symbols.BLOCK_SOLID);
            }
            x = x + 1;
        }
        y = y + 1;
    }
}

From source file:com.davidsoergel.stats.DistributionXYSeries.java

/**
 * Returns a list of all Y values associated with X values in the given range, including the bottom but not including
 * the top point// w  w w . j av a2s .co m
 *
 * @param bottom the lowest X value to consider, inclusive
 * @param top    the highest X value to consider, exclusive
 * @return
 */
public List<Double> getYList(double bottom, double top) {
    List<Double> result = new ArrayList<Double>();
    try {
        //bottom = Math.max(bottom, keys.first());  // not necessary

        // here is an annoyance: the headSet(top) call can't ever include keys.last(),
        // because either top == keys.last() in which case it's an open interval,
        // or top > keys.last(), in which case headSet throws an exception because
        // it's operating on a tailSet and top is outside the bounds.

        double last = keys.last();
        double topTrim = Math.min(top, last); // avoid the exception...

        for (Double x : keys.tailSet(bottom).headSet(topTrim)) {
            // check that a multiset iterator returns the duplicates
            int i = result.size();
            Multiset<Double> multiset = yValsPerX.get(x);
            result.addAll(multiset);
            assert result.size() == i + multiset.size();
        }

        if (top > last) // top is exclusive
        {
            result.addAll(yValsPerX.get(last)); // but do include the point
        }
    } catch (IllegalArgumentException e) {
        // there are no points in the requested range, so we just return an empty list
    }
    return result;
}

From source file:io.janusproject.util.MultisetView.java

@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }/* w  w  w .j  a v a 2 s  . c  om*/
    if (obj instanceof Multiset) {
        Multiset<?> that = (Multiset<?>) obj;

        // We can't simply check whether the entry sets are equal, since that
        // approach fails when a TreeMultiset has a comparator that returns 0
        // when passed unequal elements.
        if (size() != that.size() || entrySet().size() != that.entrySet().size()) {
            return false;
        }
        for (Entry<?> entry : that.entrySet()) {
            if (count(entry.getElement()) != entry.getCount()) {
                return false;
            }
        }
        return true;
    }
    return false;
}

From source file:de.hzi.helmholtz.Compare.PathwayComparisonWithModules.java

public Multimap<Double, String> SubsetsMatching(final PathwayWithModules firstPathway,
        final PathwayWithModules secondPathway, BiMap<Integer, Integer> newSourceGeneIdToPositionMap,
        BiMap<Integer, Integer> newTargetGeneIdToPositionMap, int Yes) {
    Multimap<Double, String> resultPerfect = TreeMultimap.create(Ordering.natural().reverse(),
            Ordering.natural());//from  www  .ja v a2s . c  o  m
    PathwayWithModules firstPathwayCopy = new PathwayWithModules(firstPathway);// Copy of the Query pathway
    PathwayWithModules secondPathwayCopy = new PathwayWithModules(secondPathway);// Copy of the Target pathway'
    // PathwayWithModules secondPathwayCopy1 = new PathwayWithModules(secondPathway);
    int currentQueryGene = 0;
    Iterator<ModuleGene> sourceGeneIt = firstPathway.moduleGeneIterator();
    List<Integer> QueryToRemove = new ArrayList<Integer>();
    List<Integer> TargetToRemove = new ArrayList<Integer>();
    while (sourceGeneIt.hasNext()) {
        currentQueryGene++;
        ModuleGene queryGene = sourceGeneIt.next();

        int currentTargetGene = 0;
        Multiset<String> qfunction = LinkedHashMultiset.create();
        List<String> qfunctionList = new ArrayList<String>();
        List<String> qactivity = new ArrayList<String>();
        List<Set<String>> qsubstrate = new ArrayList<Set<String>>();
        for (Module m : queryGene.getModule()) {
            for (Domain d : m.getDomains()) {
                qfunction.add(d.getDomainFunctionString());
                qfunctionList.add(d.getDomainFunctionString());
                qactivity.add(d.getStatus().toString());
                qsubstrate.add(d.getSubstrates());
            }
        }
        Iterator<ModuleGene> targetGeneIt = secondPathway.moduleGeneIterator();

        while (targetGeneIt.hasNext()) {
            currentTargetGene++;
            ModuleGene targetGene = targetGeneIt.next();
            Multiset<String> tfunction = LinkedHashMultiset.create();
            List<String> tfunctionList = new ArrayList<String>();
            List<String> tactivity = new ArrayList<String>();
            List<Set<String>> tsubstrate = new ArrayList<Set<String>>();
            for (Module m : targetGene.getModule()) {
                for (Domain d : m.getDomains()) {
                    tfunctionList.add(d.getDomainFunctionString());
                    tfunction.add(d.getDomainFunctionString());
                    tactivity.add(d.getStatus().toString());
                    tsubstrate.add(d.getSubstrates());
                }
            }
            Multiset<String> DomainsCovered = Multisets.intersection(qfunction, tfunction);
            if (DomainsCovered.size() == qfunction.size() && DomainsCovered.size() == tfunction.size()) {
                Multimap<Double, Multimap<String, Integer>> activityscores = myFunction.calculate(qactivity,
                        tactivity);
                Multimap<String, Integer> Functionscores = ArrayListMultimap.create();

                int TranspositionDomains = LevenshteinDistance.computeLevenshteinDistance(qfunctionList,
                        tfunctionList);
                if (TranspositionDomains > 0) {
                    TranspositionDomains = 1;
                }

                Functionscores.put(qfunction.size() + "-0", TranspositionDomains);
                Multimap<Double, Multimap<String, Integer>> substratescore = myFunction
                        .calculate(getSubstrateList(qsubstrate), getSubstrateList(tsubstrate));
                Object activityScore = activityscores.asMap().keySet().toArray()[0];
                Object substrateScore = substratescore.asMap().keySet().toArray()[0];
                double finalScore = Math
                        .round((((2.9 * 1.0) + (0.05 * Double.parseDouble(activityScore.toString().trim()))
                                + (0.05 * Double.parseDouble(substrateScore.toString().trim()))) / 3) * 100.0)
                        / 100.0;
                String ConvertedGeneIDs = "";
                if (Yes == 0) {
                    ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene),
                            newSourceGeneIdToPositionMap) + "->"
                            + reconstructWithGeneId(Integer.toString(currentTargetGene),
                                    newTargetGeneIdToPositionMap);
                } else {
                    ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentTargetGene),
                            newTargetGeneIdToPositionMap) + "->"
                            + reconstructWithGeneId(Integer.toString(currentQueryGene),
                                    newSourceGeneIdToPositionMap);
                }
                resultPerfect.put(finalScore, ConvertedGeneIDs);
                ScoreFunctionMatchMisMatch.put(ConvertedGeneIDs, Functionscores);
                ScoreStatusMatchMisMatch.putAll(ConvertedGeneIDs, activityscores.values());
                ScoreSubstrateMatchMisMatch.putAll(ConvertedGeneIDs, substratescore.values());

                TargetToRemove.add(currentTargetGene);
                QueryToRemove.add(currentQueryGene);
            }
        }

    }
    for (int i : TargetToRemove) {
        secondPathwayCopy.removeGene(i);
    }
    for (int i : QueryToRemove) {
        firstPathwayCopy.removeGene(i);
    }
    if (firstPathwayCopy.size() > 0 && secondPathwayCopy.size() > 0) {
        // Re-construct the bimaps
        newSourceGeneIdToPositionMap = HashBiMap.create();
        int temp = 0;
        for (ModuleGene e : firstPathwayCopy.getModulegenes()) {
            temp = temp + 1;
            newSourceGeneIdToPositionMap.put(e.getGeneId(), temp);
        }
        newTargetGeneIdToPositionMap = HashBiMap.create();
        temp = 0;
        for (ModuleGene e : secondPathwayCopy.getModulegenes()) {
            temp = temp + 1;
            newTargetGeneIdToPositionMap.put(e.getGeneId(), temp);
        }
        resultPerfect.putAll(SubsetIdentification(firstPathwayCopy, secondPathwayCopy,
                newSourceGeneIdToPositionMap, newTargetGeneIdToPositionMap, Yes));
    }
    System.out.println(resultPerfect);
    return resultPerfect;
}

From source file:com.koloboke.compile.KolobokeMapBackedMultiset.java

@Override
public final boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*  w  ww  .  j a va2  s  .c o m*/
    if (obj instanceof Multiset) {
        Multiset<?> that = (Multiset<?>) obj;
        /*
         * We can't simply check whether the entry sets are equal, since that
         * approach fails when a TreeMultiset has a comparator that returns 0
         * when passed unequal elements.
         */

        if (this.size() != that.size() || this.entrySet().size() != that.entrySet().size()) {
            return false;
        }
        for (Entry<?> entry : that.entrySet()) {
            if (this.count(entry.getElement()) != entry.getCount()) {
                return false;
            }
        }
        return true;
    }
    return false;
}

From source file:de.hzi.helmholtz.Compare.PathwayComparisonWithModules.java

public Multimap<Double, String> SubsetIdentification(PathwayWithModules firstPathway,
        PathwayWithModules secondPathway, BiMap<Integer, Integer> newSourceGeneIdToPositionMap,
        BiMap<Integer, Integer> newTargetGeneIdToPositionMap, int Yes) {
    Multimap<Double, String> result = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural());

    Iterator<ModuleGene> sourceGeneIt = firstPathway.moduleGeneIterator();
    int currentQueryGene = 0;
    while (sourceGeneIt.hasNext()) {
        currentQueryGene++;/*from   w  ww. ja va 2  s. co m*/
        ModuleGene queryGene = sourceGeneIt.next();
        Multimap<Integer, String> resultr = TreeMultimap.create(Ordering.natural(), Ordering.natural());
        int currentTargetGene = 0;
        Multiset<String> qfunction = LinkedHashMultiset.create();
        List<String> qfunctionList = new ArrayList<String>();
        List<String> qactivity = new ArrayList<String>();
        List<Set<String>> qsubstrate = new ArrayList<Set<String>>();
        for (Module m : queryGene.getModule()) {
            for (Domain d : m.getDomains()) {
                qfunction.add(d.getDomainFunctionString());
                qfunctionList.add(d.getDomainFunctionString());
                qactivity.add(d.getStatus().toString());
                qsubstrate.add(d.getSubstrates());
            }
        }
        List<String> TargenesSelected = new ArrayList<String>();
        Iterator<ModuleGene> targetGeneIt = secondPathway.moduleGeneIterator();
        while (targetGeneIt.hasNext()) {
            currentTargetGene++;
            ModuleGene targetGene = targetGeneIt.next();
            Multiset<String> tfunction = LinkedHashMultiset.create();
            List<String> tactivity = new ArrayList<String>();
            List<Set<String>> tsubstrate = new ArrayList<Set<String>>();
            List<String> tfunctionList = new ArrayList<String>();
            Iterator<Module> mIter = targetGene.moduleIterator();
            while (mIter.hasNext()) {
                Module m = mIter.next();
                Iterator<Domain> dIter = m.domainIterator();
                while (dIter.hasNext()) {
                    Domain d = dIter.next();
                    tfunction.add(d.getDomainFunctionString());
                    tfunctionList.add(d.getDomainFunctionString());
                    tactivity.add(d.getStatus().toString());
                    tsubstrate.add(d.getSubstrates());
                }
            }
            Multiset<String> DomainsCovered = Multisets.intersection(qfunction, tfunction);
            int Differences = Math.max(Math.abs(DomainsCovered.size() - tfunction.size()),
                    Math.abs(DomainsCovered.size() - qfunction.size()));
            if (DomainsCovered.size() == tfunction.size() && tfunction.size() > 4) {
                TargenesSelected.add(Integer.toString(currentTargetGene));
            } else {
                resultr.put(Differences, Integer.toString(currentTargetGene));
            }

        }
        int count = 0;
        if (resultr.size() > 0) {
            while (TargenesSelected.size() < 2) {
                Multiset<String> k = LinkedHashMultiset.create(resultr.values());
                Multiset<String> t = LinkedHashMultiset.create(TargenesSelected);
                Multiset<String> Covered = Multisets.intersection(k, t);
                if (Covered.size() == k.size()) {
                    break;
                }

                try {
                    TargenesSelected.addAll(
                            resultr.get(Integer.parseInt(resultr.keySet().toArray()[count].toString())));
                } catch (Exception ds) {
                }
                count = count + 1;
            }
        }
        // //System.out.println(TargenesSelected);
        //  Permutation perm = new Permutation();
        //  List<String> perms = perm.run(TargenesSelected);
        CombinationGenerator c = new CombinationGenerator(10, 10);
        List<String> perms = c.GenerateAllPossibleCombinations(TargenesSelected);
        myFunction sim = new myFunction();
        double score = 0;
        String targetIdentified = "";
        List<ModuleGene> targetGenesList = secondPathway.getModulegenes();
        for (String permu : perms) {
            String[] values = permu.replace("[", "").replace("]", "").split(",");
            List<String> mergedTargetgenes = new ArrayList<String>();
            List<Integer> ToRemove = new ArrayList<Integer>();
            List<String> tactivity = new ArrayList<String>();
            List<Set<String>> tsubstrate = new ArrayList<Set<String>>();
            for (String j : values) {
                ToRemove.add(Integer.parseInt(j.trim()));
                for (Module m : targetGenesList.get(Integer.parseInt(j.trim()) - 1).getModule()) {
                    for (Domain i : m.getDomains()) {
                        mergedTargetgenes.add(i.getDomainFunctionString());
                        tactivity.add(i.getStatus().toString());
                        tsubstrate.add(i.getSubstrates());
                    }
                }
            }
            Multimap<Double, Multimap<String, Integer>> FunctionScores = sim.calculate(qfunctionList,
                    mergedTargetgenes);
            Multimap<Double, Multimap<String, Integer>> activityscores = myFunction.calculate(qactivity,
                    tactivity);
            Multimap<Double, Multimap<String, Integer>> substratescores = myFunction
                    .calculate(getSubstrateList(qsubstrate), getSubstrateList(tsubstrate));
            Object FunctionScore = FunctionScores.asMap().keySet().toArray()[0];
            Object activityScore = activityscores.asMap().keySet().toArray()[0];
            Object substrateScore = substratescores.asMap().keySet().toArray()[0];

            double finalScore = Math
                    .round((((2.9 * Double.parseDouble(FunctionScore.toString().trim()))
                            + (0.05 * Double.parseDouble(activityScore.toString().trim()))
                            + (0.05 * Double.parseDouble(substrateScore.toString().trim()))) / 3) * 100.0)
                    / 100.0;
            targetIdentified = permu.replace(",", "+");
            String ConvertedGeneIDs = "";
            if (Yes == 0) {
                ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene),
                        newSourceGeneIdToPositionMap) + "->"
                        + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""),
                                newTargetGeneIdToPositionMap);
            } else {
                ConvertedGeneIDs = reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""),
                        newTargetGeneIdToPositionMap) + "->"
                        + reconstructWithGeneId(Integer.toString(currentQueryGene),
                                newSourceGeneIdToPositionMap);
            }
            // String ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap) + "->" + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""), newTargetGeneIdToPositionMap);

            result.put(finalScore, ConvertedGeneIDs);

            ScoreFunctionMatchMisMatch.putAll(ConvertedGeneIDs, FunctionScores.values());
            ScoreStatusMatchMisMatch.putAll(ConvertedGeneIDs, activityscores.values());
            ScoreSubstrateMatchMisMatch.putAll(ConvertedGeneIDs, substratescores.values());

        }

    }
    return result;
}

From source file:org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.java

private SortedSet<OWLIndividual> negativeExamplesBySiblingClasses(Multiset<OWLClass> positiveExamplesTypes,
        int cnt, int totalCnt) {
    logger.info("Applying sibling classes strategy...");
    SortedSet<OWLIndividual> negExamples = new TreeSet<>();

    // for each type of the positive examples
    for (OWLClass nc : positiveExamplesTypes.elementSet()) {
        int frequency = positiveExamplesTypes.count(nc);

        // get sibling classes
        Set<OWLClass> siblingClasses = sr.getSiblingClasses(nc);
        siblingClasses = filterByNamespace(siblingClasses);
        logger.info("Sibling classes: " + siblingClasses);

        int limit = (int) Math
                .ceil(((double) frequency / positiveExamplesTypes.size()) / siblingClasses.size() * cnt);

        // get instances for each sibling class
        for (OWLClass siblingClass : siblingClasses) {
            SortedSet<OWLIndividual> individuals = sr.getIndividualsExcluding(siblingClass, nc, totalCnt);
            individuals.removeAll(negExamples);
            SetManipulation.stableShrink(individuals, limit);
            negExamples.addAll(individuals);
        }/*w w w.  ja  v a  2s  . c om*/
    }
    negExamples = SetManipulation.stableShrink(negExamples, cnt);
    logger.info("Negative examples(" + negExamples.size() + "): " + negExamples);
    return negExamples;
}

From source file:com.formulasearchengine.mathosphere.mlp.text.MathConverter.java

private String getTex(WtNode i, boolean force) {
    if (i.get(0) instanceof WtText) {
        String content = ((WtText) i.get(0)).getContent().trim();
        content = TextExtractorMapper.unescape(content);
        String tex = wiki2Tex(content);
        if (tex.length() > 0 && (content.length() == 1 || (content.length() < 100 && !content.equals(tex)))) {
            Multiset<String> idents;
            try {
                idents = TexInfo.getIdentifiers(tex, texInfoUrl);
            } catch (XPathExpressionException | ParserConfigurationException | IOException | SAXException
                    | TransformerException ignored) {
                return null;
            }// w w  w .  j a v  a 2 s.  c o m
            if (idents.size() == 0 && !force) {
                return null;
            }
            if (i instanceof WtBold) {
                tex = "\\mathbf{" + tex + "}";
            }
            return tex;
        }
        if (force) {
            return tex;
        }
    }
    return null;
}

From source file:org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.java

private SortedSet<OWLIndividual> negativeExamplesBySuperClasses(Multiset<OWLClass> positiveExamplesTypes,
        Set<OWLIndividual> negativeExamples, int cnt, int totalCnt) {
    logger.info("Applying super class strategy...");
    SortedSet<OWLIndividual> negExamples = new TreeSet<>();
    //for each type of the positive examples
    for (OWLClass nc : positiveExamplesTypes.elementSet()) {
        int frequency = positiveExamplesTypes.count(nc);
        //get super classes
        Set<OWLClassExpression> superClasses = sr.getSuperClasses(nc);
        superClasses.remove(df.getOWLThing());
        //               superClasses.remove(Thing.instance);
        superClasses.remove(df.getOWLClass(OWLRDFVocabulary.RDFS_RESOURCE.getIRI()));
        superClasses = filterByNamespace(superClasses);
        logger.info("Super classes: " + superClasses);

        int limit = (int) Math
                .ceil(((double) frequency / positiveExamplesTypes.size()) / superClasses.size() * cnt);
        //get instances for each super class
        for (OWLClassExpression superClass : superClasses) {
            SortedSet<OWLIndividual> individuals = sr.getIndividualsExcluding(superClass, nc, totalCnt);
            individuals.removeAll(negativeExamples);
            individuals.removeAll(negExamples);
            SetManipulation.stableShrink(individuals, limit);
            negExamples.addAll(individuals);
        }//from  w  w  w  .j a  v  a2s . c  o  m
    }
    negExamples = SetManipulation.stableShrink(negExamples, cnt);
    logger.info("Negative examples(" + negExamples.size() + "): " + negExamples);
    return negExamples;
}