use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AbstractMapper method unmap.
@Override
public InMemoryAtomSet unmap(InMemoryAtomSet atomset) {
InMemoryAtomSet mapped;
try {
mapped = atomset.getClass().newInstance();
} catch (InstantiationException e) {
mapped = new LinkedListAtomSet();
} catch (IllegalAccessException e) {
mapped = new LinkedListAtomSet();
}
CloseableIteratorWithoutException<Atom> it = atomset.iterator();
while (it.hasNext()) {
mapped.add(this.unmap(it.next()));
}
it.close();
return mapped;
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AbstractMapper method unmap.
@Override
public Rule unmap(Rule rule) {
InMemoryAtomSet body = this.unmap(rule.getBody());
InMemoryAtomSet head = this.unmap(rule.getHead());
return DefaultRuleFactory.instance().create(rule.getLabel(), body, head);
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AtomSetUtils method minus.
public static InMemoryAtomSet minus(InMemoryAtomSet a1, InMemoryAtomSet a2) {
InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
CloseableIteratorWithoutException<Atom> it = a1.iterator();
while (it.hasNext()) {
Atom a = it.next();
if (!a2.contains(a)) {
atomset.add(a);
}
}
return atomset;
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AtomSetUtils method union.
public static InMemoryAtomSet union(InMemoryAtomSet a1, InMemoryAtomSet a2) {
InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
CloseableIteratorWithoutException<Atom> it = a1.iterator();
while (it.hasNext()) {
Atom a = it.next();
atomset.add(new DefaultAtom(a));
}
it = a2.iterator();
while (it.hasNext()) {
Atom a = it.next();
if (!atomset.contains(a)) {
atomset.add(new DefaultAtom(a));
}
}
return atomset;
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWL2ParserTest method objectOneOf1.
@Test
public void objectOneOf1() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + " [ owl:oneOf ( :i1 ) ] " + " rdfs:subClassOf :A . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof InMemoryAtomSet) {
++nbRules;
InMemoryAtomSet a = (InMemoryAtomSet) o;
CloseableIteratorWithoutException<Atom> bodyIt = a.iterator();
Assert.assertTrue(bodyIt.hasNext());
Atom body = bodyIt.next();
Assert.assertFalse(bodyIt.hasNext());
Assert.assertEquals(A, body.getPredicate());
Assert.assertTrue(!body.getTerm(0).isConstant() || body.getTerm(0).equals(I1));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Aggregations