Search in sources :

Example 6 with InfModel

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

the class JenaOWLReasoningServiceTest method testSubclassOf.

/**
	 * Tests rdfs:subClassOf inference with OWLReasoner
	 */
@Test
public void testSubclassOf() {
    log.info("Testing rdfs:subClassOf inference with OWL reasoner");
    // Prepare data
    TestData.alexdma.addProperty(RDF.type, TestData.foaf_Person);
    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
    // Am I a foaf:Agent?
    log.info("Instantiating the OWL reasoner");
    InfModel inferred = reasoningService.run(input);
    Statement isAgent = TestData.model.createStatement(TestData.alexdma, RDF.type, TestData.foaf_Agent);
    //		log.info("Statements: {}",
    //				TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    log.info("Is any foaf:Person a foaf:Agent...? {}", inferred.contains(isAgent));
    assertTrue(inferred.contains(isAgent));
    // 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)

Example 7 with InfModel

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

the class JenaRDFSReasoningServiceTest method testRDFSSubclassOf.

/**
	 * Tests rdfs:subClassOf inference with RDFSReasoner
	 */
@Test
public void testRDFSSubclassOf() {
    log.info("Testing rdfs:subClassOf inference with RDFS reasoner");
    // Prepare data
    TestData.alexdma.addProperty(RDF.type, TestData.foaf_Person);
    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
    // Is alexdma foaf:Agent?
    InfModel inferred = reasoningService.run(input);
    Statement isAgent = TestData.model.createStatement(TestData.alexdma, RDF.type, TestData.foaf_Agent);
    //		log.info("Statements: {}",
    //				TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    log.info("Is any foaf:Person is also a foaf:Agent...(true)? {}", inferred.contains(isAgent));
    assertTrue(inferred.contains(isAgent));
    // 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)

Example 8 with InfModel

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

the class JenaOWLReasoningServiceTest method testDisjointness.

/**
	 * Tests the owl:disjointWith inferences
	 */
@Test
public void testDisjointness() {
    log.info("Testing owl:disjointWith inferences with OWL reasoner");
    // We assure everything is clean
    TestData.alexdma.removeProperties();
    TestData.alexdma.addProperty(RDF.type, TestData.foaf_Organization);
    TestData.alexdma.addProperty(RDF.type, TestData.foaf_Person);
    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
    // Can I be a foaf:Organization and a foaf:Person at the same time?
    log.info("Instantiating the OWL reasoner");
    // Run the reasoner
    InfModel inferred = reasoningService.run(input);
    //		log.info("Statements: {}",
    //				TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    ValidityReport validity = inferred.validate();
    log.info("Can I be a foaf:Organization and a foaf:Person at the same time...? {}", validity.isValid());
    assertTrue(!validity.isValid());
    // Clean shared resource
    TestData.alexdma.removeProperties();
}
Also used : ValidityReport(com.hp.hpl.jena.reasoner.ValidityReport) 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)

Example 9 with InfModel

use of com.hp.hpl.jena.rdf.model.InfModel 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 10 with InfModel

use of com.hp.hpl.jena.rdf.model.InfModel 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

InfModel (com.hp.hpl.jena.rdf.model.InfModel)10 Model (com.hp.hpl.jena.rdf.model.Model)7 Statement (com.hp.hpl.jena.rdf.model.Statement)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)2 Query (com.hp.hpl.jena.query.Query)1 QueryExecution (com.hp.hpl.jena.query.QueryExecution)1 Property (com.hp.hpl.jena.rdf.model.Property)1 Resource (com.hp.hpl.jena.rdf.model.Resource)1 ValidityReport (com.hp.hpl.jena.reasoner.ValidityReport)1 GenericRuleReasoner (com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 AbstractRuleAdapter (org.apache.stanbol.rules.adapters.AbstractRuleAdapter)1 Recipe (org.apache.stanbol.rules.base.api.Recipe)1 Rule (org.apache.stanbol.rules.base.api.Rule)1 RuleAdapter (org.apache.stanbol.rules.base.api.RuleAdapter)1