use of org.apache.stanbol.enhancer.benchmark.TripleMatcher in project stanbol by apache.
the class TripleMatcherGroupImpl method getMatchingSubjects.
@Override
public Set<IRI> getMatchingSubjects(ImmutableGraph g) {
if (matchers.isEmpty()) {
return new HashSet<IRI>();
}
// For all matchers, find the set of subjects that match
// and compute the intersection of those sets
Set<IRI> intersection = null;
for (TripleMatcher m : matchers) {
final Set<IRI> s = new HashSet<IRI>();
final Iterator<Triple> it = g.iterator();
while (it.hasNext()) {
final Triple t = it.next();
if (m.matches(t)) {
final BlankNodeOrIRI n = t.getSubject();
if (n instanceof IRI) {
s.add((IRI) n);
} else {
// TODO do we need to handle non-IRI subjects?
}
}
}
if (intersection == null) {
intersection = s;
} else {
intersection.retainAll(s);
}
}
return intersection;
}
Aggregations