Search in sources :

Example 1 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method dataRangeComplementOf.

@Test
public void dataRangeComplementOf() throws OWL2ParserException {
    // D(Y) :- p(X, Y).
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":D rdf:type rdfs:Datatype ." + ":E rdf:type rdfs:Datatype." + ":p rdfs:range [owl:complementOf [owl:intersectionOf ( :D :E ) ]] .");
    int nbAssertions = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            Assert.assertTrue(o instanceof Rule);
            ++nbAssertions;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbAssertions);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 2 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method illegalAllValuesFromMaskedInIntersection.

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

Example 3 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method hasKeyWithUnion.

@Test
public void hasKeyWithUnion() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class . " + ":B a owl:Class . " + ":p a owl:ObjectProperty . " + ":q a owl:DatatypeProperty . " + "[owl:unionOf( :A :B [owl:oneOf (:i1)] ) ] owl:hasKey (:p :q) .");
    int nbAssertions = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            Assert.assertTrue(o instanceof Rule);
            ++nbAssertions;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 6, nbAssertions);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 4 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method hasKey.

// /////////////////////////////////////////////////////////////////////////
// HAS KEY
// /////////////////////////////////////////////////////////////////////////
@Test
public void hasKey() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class . " + ":p a owl:ObjectProperty . " + ":q a owl:ObjectProperty . " + ":A owl:hasKey (:p :q) .");
    int nbAssertions = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            Assert.assertTrue(o instanceof Rule);
            ++nbAssertions;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbAssertions);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 5 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method objectPropertyDomain.

@Test
public void objectPropertyDomain() {
    // C(Y) :- p(X, Y).
    try {
        OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":A rdf:type owl:Class . " + ":p rdfs:domain :A .");
        boolean found = false;
        while (parser.hasNext()) {
            Object o = parser.next();
            if (!(o instanceof Prefix)) {
                Rule r = (Rule) o;
                Atom property = (Atom) r.getBody().iterator().next();
                Assert.assertEquals(P, property.getPredicate());
                Atom classs = (Atom) r.getHead().iterator().next();
                Assert.assertEquals(A, classs.getPredicate());
                Assert.assertEquals(property.getTerm(0), classs.getTerm(0));
                found = true;
            }
        }
        parser.close();
        Assert.assertTrue("Number of assertions found:", found);
    } catch (Exception e) {
        Assert.assertFalse(e.getMessage(), true);
    }
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) 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

Prefix (fr.lirmm.graphik.util.Prefix)31 Test (org.junit.Test)25 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)21 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)15 Rule (fr.lirmm.graphik.graal.api.core.Rule)12 Atom (fr.lirmm.graphik.graal.api.core.Atom)6 Term (fr.lirmm.graphik.graal.api.core.Term)3 Map (java.util.Map)3 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)2 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)2 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)2 DefaultURI (fr.lirmm.graphik.util.DefaultURI)2 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)2 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Query (org.apache.jena.query.Query)2 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)1 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)1 Variable (fr.lirmm.graphik.graal.api.core.Variable)1