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


Java InfModel.leaveCriticalSection方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.InfModel.leaveCriticalSection方法的典型用法代码示例。如果您正苦于以下问题:Java InfModel.leaveCriticalSection方法的具体用法?Java InfModel.leaveCriticalSection怎么用?Java InfModel.leaveCriticalSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.rdf.model.InfModel的用法示例。


在下文中一共展示了InfModel.leaveCriticalSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
 * Add OWL rules and compute the forward chain.
 * 
 * @param base
 * @param datasetPaths
 */
public static void run(String base) {

	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + base + "/model.nt");

	logger.info("Model size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(base
				+ "/model-fwc.nt")), infModel, Lang.NT);
		logger.info("Model generated.");
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file model-fwc.nt was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}

	new File(base + "/model.nt").delete();

}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:40,代码来源:PelletReasoner.java

示例2: closure

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void closure(String input, String output) {
	
	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + input);

	logger.info("Model = "+input+", size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(output)), 
				infModel, Lang.NT);
		logger.info("Model generated at "+output);
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file "+output+" was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}
	
}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:32,代码来源:PelletReasoner.java


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