当前位置: 首页>>代码示例>>Java>>正文


Java Reasoner.setDerivationLogging方法代码示例

本文整理汇总了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
	}
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:46,代码来源:Task07_Nestor_Lopez.java


注:本文中的com.hp.hpl.jena.reasoner.Reasoner.setDerivationLogging方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。