本文整理汇总了Java中com.hp.hpl.jena.reasoner.Reasoner.setDerivationLogging方法的典型用法代码示例。如果您正苦于以下问题:Java Reasoner.setDerivationLogging方法的具体用法?Java Reasoner.setDerivationLogging怎么用?Java Reasoner.setDerivationLogging使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.reasoner.Reasoner
的用法示例。
在下文中一共展示了Reasoner.setDerivationLogging方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "example6.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// ** TASK 7.1: List all individuals of "Person" **
System.out.println("\nTASK 7.1 - List all individuals of Person\n");
OntClass person = model.getOntClass(ns+"Person");
ExtendedIterator<? extends OntResource> itr = person.listInstances();
while(itr.hasNext()){
Individual persons = (Individual) itr.next();
System.out.println("Person : " + persons);
}
// ** TASK 7.2: List all subclasses of "Person" **
System.out.println("\nTASK 7.2 - List all subclasses of Person\n");
itr = person.listSubClasses(false);
while (itr.hasNext()) {
OntClass ontClass = (OntClass) itr.next();
System.out.println("Subclass : " + ontClass);
}
// ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. **
// ** TIP: you need some inference... **
System.out.println("\nTASK 7.3 - Make the necessary changes to get as well indirect instances and subclasses\n");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(model);
reasoner.setDerivationLogging(true);
InfModel inf = ModelFactory.createInfModel(reasoner, model);
StmtIterator i = inf.listStatements(person, null, (RDFNode) null);
while(i.hasNext()){
Statement s = i.nextStatement();
System.out.println("Statement: \n" + s.asTriple()); //turtle format
}
}