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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations