Search in sources :

Example 21 with Prefix

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

the class OWL2ParserTest method subDataRange.

@Test
public void subDataRange() throws OWL2ParserException {
    // p(X,Y) D(Y) :- A(X).
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class. " + ":D1 a rdfs:Datatype. " + ":D2 a rdfs:Datatype. " + ":D3 a rdfs:Datatype. " + ":p rdf:type owl:DatatypeProperty . " + "[a owl:Restriction; owl:onProperty :p; owl:someValuesFrom [a rdfs:Datatype; owl:unionOf (:D1 :D2 :D3)]] rdfs:subClassOf :A.");
    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:", 3, 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 22 with Prefix

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

the class OWL2ParserTest method objectMinCardinality0InRightHandSide.

@Test
public void objectMinCardinality0InRightHandSide() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " :B rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onClass :A ; " + " owl:minCardinality 0 ] . ");
    int nbAssertions = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            ++nbAssertions;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 0, nbAssertions);
}
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 23 with Prefix

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

the class OWL2ParserTest method complexObjectMinCardinality0InRightHandSide.

@Test
public void complexObjectMinCardinality0InRightHandSide() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " :B rdfs:subClassOf [a owl:Restriction; owl:onProperty :p; owl:someValuesFrom [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onClass :A ; " + " owl:minCardinality 0 ] ]. ");
    int nbAssertions = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            ++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) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 24 with Prefix

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

the class OWL2ParserTest method dataRangeUnionOf.

@Test
public void dataRangeUnionOf() throws OWL2ParserException {
    // D(Y) :- p(X, Y).
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":D1 a rdfs:Datatype." + ":D2 a rdfs:Datatype." + ":p rdfs:range [a rdfs:Datatype; owl:complementOf [a rdfs:Datatype; owl:unionOf ( :D1 :D2 ) ]] .");
    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:", 2, 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 25 with Prefix

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

the class OWL2ParserTest method illegalAllValuesFromMaskedSomeValuesFrom.

// @Test
// public void assertionDataProperty() {
// try {
// OWLParser parser = new OWLParser(
// "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . "
// + "@prefix owl: <http://www.w3.org/2002/07/owl#> . "
// + "@prefix test: <http://test.org/> . "
// + "test:property rdf:type owl:DatatypeProperty . "
// + "test:a test:property \"test\" ." + "");
// 
// boolean found = false;
// while (parser.hasNext()) {
// Object o = parser.next();
// if (!(o instanceof Prefix)) {
// Atom a = (Atom) o;
// Assert.assertEquals(new Predicate("test:property", 2),
// a.getPredicate());
// CloseableIteratorWithoutException<Term> it = a.iterator();
// Assert.assertEquals(DefaultTermFactory.instance()
// .createConstant("test:a"), it.next());
// Assert.assertEquals(DefaultTermFactory.instance()
// .createLiteral("test"), it.next());
// found = true;
// }
// }
// 
// Assert.assertTrue("Number of assertions found:", found);
// } catch (Exception e) {
// Assert.assertFalse(e.getMessage(), true);
// }
// }
// /////////////////////////////////////////////////////////////////////////
// MORE COMPLEX TEST
// /////////////////////////////////////////////////////////////////////////
@Test
public void illegalAllValuesFromMaskedSomeValuesFrom() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + " :A a owl:Class. " + ":B a owl:Class. " + ":p a owl:ObjectProperty. " + "[rdf:type owl:Restriction; " + "    owl:onProperty :p; " + "    owl:someValuesFrom [rdf:type owl:Restriction; " + "        owl:onProperty :p ; " + "        owl:allValuesFrom :A] " + "] rdfs:subClassOf :B .");
    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)

Aggregations

Prefix (fr.lirmm.graphik.util.Prefix)33 Test (org.junit.Test)27 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)23 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)17 Rule (fr.lirmm.graphik.graal.api.core.Rule)14 Atom (fr.lirmm.graphik.graal.api.core.Atom)6 Term (fr.lirmm.graphik.graal.api.core.Term)3 Map (java.util.Map)3 Query (com.hp.hpl.jena.query.Query)2 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 Triple (com.hp.hpl.jena.graph.Triple)1 QueryParseException (com.hp.hpl.jena.query.QueryParseException)1 Template (com.hp.hpl.jena.sparql.syntax.Template)1