Search in sources :

Example 6 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint 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);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Example 7 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWL2ParserTest method objectMaxCardinality0.

@Test
public void objectMaxCardinality0() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " :A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onClass :B ; " + " owl:maxCardinality 0 ] . ");
    int nbRules = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (o instanceof DefaultNegativeConstraint) {
            ++nbRules;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 8 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWL2ParserTest method dataMaxCardinality0.

@Test
public void dataMaxCardinality0() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Datatype . " + ":p rdf:type owl:DatatypeProperty . " + " :A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onDataRange :B ; " + " owl:maxCardinality 0 ] . ");
    int nbRules = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (o instanceof DefaultNegativeConstraint) {
            ++nbRules;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 9 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWLAxiomParser method visit.

@Override
public Iterable<? extends Object> visit(OWLAsymmetricObjectPropertyAxiom arg) {
    InMemoryAtomSet atomset = arg.getProperty().accept(propertyVisitorXY);
    atomset.addAll(arg.getProperty().accept(propertyVisitorYX));
    return Collections.singleton(new DefaultNegativeConstraint(atomset));
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 10 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWL2ParserTest method irreflexiveObjectPropertyOf.

@Test
public void irreflexiveObjectPropertyOf() {
    // ! :- p(X,X) .
    try {
        OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:IrreflexiveProperty . ");
        int nbRules = 0;
        while (parser.hasNext()) {
            Object o = parser.next();
            if (o instanceof DefaultNegativeConstraint) {
                ++nbRules;
                Rule r = (Rule) o;
                CloseableIteratorWithoutException<Atom> it = r.getBody().iterator();
                Atom b = it.next();
                Assert.assertFalse(it.hasNext());
                Assert.assertEquals(P, b.getPredicate());
                Assert.assertEquals(b.getTerm(0), b.getTerm(1));
            }
        }
        parser.close();
        Assert.assertEquals("Number of assertions found:", 1, nbRules);
    } catch (Exception e) {
        Assert.assertFalse(e.getMessage(), true);
    }
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Atom(fr.lirmm.graphik.graal.api.core.Atom) OWL2ParserException(fr.lirmm.graphik.graal.io.owl.OWL2ParserException) CloseableIteratorWithoutException(fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException) IteratorException(fr.lirmm.graphik.util.stream.IteratorException) Test(org.junit.Test)

Aggregations

DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)12 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)6 Test (org.junit.Test)6 Atom (fr.lirmm.graphik.graal.api.core.Atom)5 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)5 Term (fr.lirmm.graphik.graal.api.core.Term)4 Rule (fr.lirmm.graphik.graal.api.core.Rule)2 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)2 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 ParseError (fr.lirmm.graphik.graal.api.io.ParseError)1 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)1 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)1 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)1 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)1 LinkedList (java.util.LinkedList)1 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)1 OWLPropertyExpression (org.semanticweb.owlapi.model.OWLPropertyExpression)1 SWRLRule (org.semanticweb.owlapi.model.SWRLRule)1