use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AtomSetUtils method sep.
/**
* Return the terms occuring both in Q\P and P
*/
public static LinkedList<Term> sep(InMemoryAtomSet a1, InMemoryAtomSet a2) {
InMemoryAtomSet pBar = minus(a2, a1);
LinkedList<Term> sep = new LinkedList<Term>();
for (Term t : pBar.getTerms()) {
for (Term x : a2.getTerms()) if (x.equals(t))
sep.add(t);
}
return sep;
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWL2ParserTest method unionOfObjectOneOf.
@Test
public void unionOfObjectOneOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + "[ owl:unionOf ( [ owl:oneOf ( :i1 :i2 ) ] [ owl:oneOf ( :i3 :i4 ) ] ) ] rdfs:subClassOf :A. ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof InMemoryAtomSet) {
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
while (it.hasNext()) {
it.next();
++nbRules;
}
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 4, nbRules);
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWL2ParserTest method objectOneOf.
@Test
public void objectOneOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + "[ owl:oneOf ( :i1 :i2 :i3 ) ] rdfs:subClassOf :A . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof InMemoryAtomSet) {
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
while (it.hasNext()) {
Atom a = it.next();
++nbRules;
Assert.assertTrue(a.getTerm(0).equals(I1) || a.getTerm(0).equals(I2) || a.getTerm(0).equals(I3));
Assert.assertEquals(A, a.getPredicate());
}
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 3, nbRules);
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWL2ParserTest method classAssertion.
// /////////////////////////////////////////////////////////////////////////
// ASSERTIONS
// /////////////////////////////////////////////////////////////////////////
@Test
public void classAssertion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":i1 a :A ." + "");
int nbFacts = 0;
while (parser.hasNext()) {
Object o = parser.next();
if ((o instanceof InMemoryAtomSet)) {
++nbFacts;
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(A, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbFacts);
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWL2ParserTest method complexClassAssertion.
@Test
public void complexClassAssertion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":i1 a [owl:intersectionOf ( :A [owl:complementOf :B] ) ] ." + "");
int nbFacts = 0;
int nbConstraint = 0;
while (parser.hasNext()) {
Object o = parser.next();
if ((o instanceof InMemoryAtomSet)) {
++nbFacts;
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(A, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
if ((o instanceof DefaultNegativeConstraint)) {
++nbConstraint;
CloseableIteratorWithoutException<Atom> it = ((DefaultNegativeConstraint) o).getBody().iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(B, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbFacts);
Assert.assertEquals("Number of assertions found:", 1, nbConstraint);
}
Aggregations