本文整理汇总了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();
}
示例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();
}
}