Search in sources :

Example 21 with Statement

use of com.hp.hpl.jena.rdf.model.Statement in project stanbol by apache.

the class JenaRDFSReasoningServiceTest method testRDFSSubPropertyOf.

@Test
public void testRDFSSubPropertyOf() {
    log.info("Testing rdfs:subPropertyOf inference with RDFS reasoner");
    // We invent a property to extend foaf:knows
    Property collegueOf = TestData.model.createProperty(TestData.TEST_NS + "collegueOf");
    collegueOf.addProperty(RDFS.subPropertyOf, TestData.foaf_knows);
    // Prepare data
    TestData.alexdma.addProperty(collegueOf, TestData.enridaga);
    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
    // Does alexdma know enridaga?
    InfModel inferred = reasoningService.run(input);
    Statement knowsHim = TestData.model.createStatement(TestData.alexdma, TestData.foaf_knows, TestData.enridaga);
    // log.info("Statements: {}", TestUtils.printStatements(inferred,
    //		TestData.enridaga, RDF.type));
    log.info("Does alexdma foaf:knows enridaga?...(true)? {}", inferred.contains(knowsHim));
    assertTrue(inferred.contains(knowsHim));
    // Reset resource to be clean for other tests
    TestData.alexdma.removeProperties();
}
Also used : Statement(com.hp.hpl.jena.rdf.model.Statement) InfModel(com.hp.hpl.jena.rdf.model.InfModel) Model(com.hp.hpl.jena.rdf.model.Model) InfModel(com.hp.hpl.jena.rdf.model.InfModel) Property(com.hp.hpl.jena.rdf.model.Property) Test(org.junit.Test)

Example 22 with Statement

use of com.hp.hpl.jena.rdf.model.Statement in project stanbol by apache.

the class JenaRDFSReasoningServiceTest method testRDFSRange.

@Test
public void testRDFSRange() {
    log.info("Testing rdfs:range inference with RDFS reasoner");
    // Prepare data
    TestData.alexdma.addProperty(TestData.foaf_knows, TestData.enridaga);
    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
    // Is enridaga a foaf:Person?
    InfModel inferred = reasoningService.run(input);
    Statement isPerson = TestData.model.createStatement(TestData.enridaga, RDF.type, TestData.foaf_Person);
    //		log.info("Statements: {}", TestUtils.printStatements(inferred,
    //				TestData.enridaga, RDF.type));
    log.info("Is any rdfs:range of foaf:knows a foaf:Person...(true)? {}", inferred.contains(isPerson));
    assertTrue(inferred.contains(isPerson));
    // Reset resource to be clean for other tests
    TestData.alexdma.removeProperties();
}
Also used : Statement(com.hp.hpl.jena.rdf.model.Statement) InfModel(com.hp.hpl.jena.rdf.model.InfModel) Model(com.hp.hpl.jena.rdf.model.Model) InfModel(com.hp.hpl.jena.rdf.model.InfModel) Test(org.junit.Test)

Aggregations

Statement (com.hp.hpl.jena.rdf.model.Statement)22 Model (com.hp.hpl.jena.rdf.model.Model)13 InfModel (com.hp.hpl.jena.rdf.model.InfModel)7 HashSet (java.util.HashSet)7 Test (org.junit.Test)7 Resource (com.hp.hpl.jena.rdf.model.Resource)6 StmtIterator (com.hp.hpl.jena.rdf.model.StmtIterator)6 ReasoningServiceException (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException)6 InconsistentInputException (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException)5 UnsupportedTaskException (org.apache.stanbol.reasoners.servicesapi.UnsupportedTaskException)5 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)5 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)4 Rule (com.hp.hpl.jena.reasoner.rulesys.Rule)3 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)3 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)3 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)3 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)3 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)3 OntModel (com.hp.hpl.jena.ontology.OntModel)2 Property (com.hp.hpl.jena.rdf.model.Property)2