Example usage for com.google.common.collect Sets union

List of usage examples for com.google.common.collect Sets union

Introduction

In this page you can find the example usage for com.google.common.collect Sets union.

Prototype

public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) 

Source Link

Document

Returns an unmodifiable view of the union of two sets.

Usage

From source file:org.dllearner.algorithms.qtl.impl.QueryTreeFactoryBaseInv.java

public static void main(String[] args) throws Exception {
    QueryTreeFactory factory = new QueryTreeFactoryBaseInv();
    factory.setMaxDepth(2);// ww w .  ja v  a  2s .c o m
    factory.addDropFilters(
            new PredicateDropStatementFilter(
                    Sets.union(Sets.union(StopURIsDBpedia.get(), StopURIsRDFS.get()), StopURIsOWL.get())),
            new ObjectDropStatementFilter(StopURIsOWL.get()),
            new NamespaceDropStatementFilter(Sets.newHashSet("http://dbpedia.org/property/",
                    "http://purl.org/dc/terms/", "http://dbpedia.org/class/yago/", FOAF.getURI())));
    ConciseBoundedDescriptionGenerator cbdGen = new SymmetricConciseBoundedDescriptionGeneratorImpl(
            SparqlEndpoint.getEndpointDBpedia());
    String resourceURI = "http://dbpedia.org/resource/Athens";
    Model cbd = cbdGen.getConciseBoundedDescription(resourceURI, 1);
    RDFResourceTree queryTree = factory.getQueryTree(resourceURI, cbd);
    System.out.println(queryTree.getStringRepresentation());
    System.out.println(QueryTreeUtils.toSPARQLQuery(queryTree));
}

From source file:org.dllearner.algorithms.qtl.impl.QueryTreeFactoryBase.java

public static void main(String[] args) throws Exception {
    QueryTreeFactory factory = new QueryTreeFactoryBase();
    factory.setMaxDepth(2);//from   ww w  . j a  v  a 2s .  c om
    factory.addDropFilters(
            new PredicateDropStatementFilter(
                    Sets.union(Sets.union(StopURIsDBpedia.get(), StopURIsRDFS.get()), StopURIsOWL.get())),
            new ObjectDropStatementFilter(StopURIsOWL.get()),
            new NamespaceDropStatementFilter(Sets.newHashSet("http://dbpedia.org/property/",
                    "http://purl.org/dc/terms/", "http://dbpedia.org/class/yago/", FOAF.getURI())));
    ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(
            SparqlEndpoint.getEndpointDBpedia());
    String resourceURI = "http://dbpedia.org/resource/Athens";
    Model cbd = cbdGen.getConciseBoundedDescription(resourceURI, 2);
    RDFResourceTree queryTree = factory.getQueryTree(resourceURI, cbd);
    System.out.println(queryTree.getStringRepresentation());
    System.out.println(QueryTreeUtils.toSPARQLQuery(queryTree));
}

From source file:th.algorithms.propinquitydynamics.utils.CalculationTable.java

public static Set<Integer> CalculateCri(Set<Integer> Nr, Set<Integer> Ni, Set<Integer> nnNr,
        Set<Integer> nnNi) {
    // (Nr ^ nnNi) + (Ni ^ nnNr) + (Ni ^ nnNi)
    return Sets.union(Sets.union(Sets.intersection(Nr, nnNi), Sets.intersection(Ni, nnNr)),
            Sets.intersection(Ni, nnNi)).copyInto(new HashSet<Integer>(20));
}

From source file:th.algorithms.propinquitydynamics.utils.CalculationTable.java

public static Set<Integer> CalculateCrd(Set<Integer> Nr, Set<Integer> Nd, Set<Integer> nnNr,
        Set<Integer> nnNd) {
    // (Nr ^ nnNd) + (Nd ^ nnNr) + (Nd ^ nnNd)
    return Sets.union(Sets.union(Sets.intersection(Nr, nnNd), Sets.intersection(Nd, nnNr)),
            Sets.intersection(Nd, nnNd)).copyInto(new HashSet<Integer>(20));
}

From source file:com.facebook.buck.cli.TargetGraphTestParsing.java

public static TargetGraph expandedTargetGraphToIncludeTestsForTargets(ProjectGraphParser parser,
        TargetGraph original, ImmutableSet<BuildTarget> targets) throws IOException, InterruptedException {
    ImmutableSet<BuildTarget> explicitTestTargets;
    explicitTestTargets = TargetGraphAndTargets.getExplicitTestTargets(targets, original, true);
    Iterable<BuildTarget> targetsWithTests = Sets.union(targets, explicitTestTargets);

    return parser.buildTargetGraphForTargetNodeSpecs(
            Iterables.transform(targetsWithTests, BuildTargetSpec.TO_BUILD_TARGET_SPEC));
}

From source file:th.algorithms.propinquitydynamics.utils.CalculationTable.java

public static Set<Integer> CalculateCii(Set<Integer> Nr, Set<Integer> Ni, Set<Integer> nnNr,
        Set<Integer> nnNi) {
    // (Nr + Ni) ^ (nnNr + nnNi)
    return Sets.intersection(Sets.union(Nr, Ni), Sets.union(nnNr, nnNi)).copyInto(new HashSet<Integer>(20));
}

From source file:org.eclipse.buildship.core.workspace.internal.ManagedModelMergingStrategy.java

/**
 * Calculates the updated state./*  w w  w.j  a v  a 2 s .c  om*/
 *
 * @param current elements currently defined on the project
 * @param model elements defined in the Gradle model
 * @param managed elements managed by Buildship
 * @return the description of the updated state
 */
public static <T> Result<T> calculate(Set<T> current, Set<T> model, Set<T> managed) {
    Set<T> missing = Sets.difference(current, model);
    Set<T> removed = Sets.intersection(missing, managed);
    Set<T> notRemoved = Sets.difference(missing, removed);
    Set<T> added = Sets.difference(model, current);
    Set<T> nextElements = Sets.union(model, notRemoved);
    Set<T> nextManaged = Sets.difference(Sets.union(managed, added), removed);

    return new Result<T>(nextElements, nextManaged);
}

From source file:org.bigwave.similarity.Shingle.java

public static float jaccard_similarity_coeff(Set<String> shinglesA, Set<String> shinglesB) {
    float neumerator = Sets.intersection(shinglesA, shinglesB).size();
    float denominator = Sets.union(shinglesA, shinglesB).size();
    return neumerator / denominator;
}

From source file:th.algorithms.propinquitydynamics.utils.CalculationTable.java

public static Set<Integer> CalculateCdd(Set<Integer> Nr, Set<Integer> Nd, Set<Integer> nnNr,
        Set<Integer> nnNd) {
    // (Nr + Nd) ^ (nnNr + nnNd)
    return Sets.intersection(Sets.union(Nr, Nd), Sets.union(nnNr, nnNd)).copyInto(new HashSet<Integer>(20));
}

From source file:com.github.gdfm.shobaidogu.StatsUtils.java

/**
 * Computes the Jaccard overlap between two sets.
 * /*  ww w  .j  av a2 s  .c  o  m*/
 * @param s1
 *          first set.
 * @param s2
 *          second set.
 * @return the Jaccard overlap.
 */
public static <T> double jaccardOverlap(Set<T> s1, Set<T> s2) {
    checkNotNull(s1);
    checkNotNull(s2);
    if (s1.isEmpty() || s2.isEmpty())
        return 0;
    double intersectSize = Sets.intersection(s1, s2).size();
    double unionSize = Sets.union(s1, s2).size();
    return intersectSize / unionSize;
}