本文整理汇总了Java中org.mindswap.pellet.jena.PelletReasonerFactory类的典型用法代码示例。如果您正苦于以下问题:Java PelletReasonerFactory类的具体用法?Java PelletReasonerFactory怎么用?Java PelletReasonerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PelletReasonerFactory类属于org.mindswap.pellet.jena包,在下文中一共展示了PelletReasonerFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createModel
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
/**
* Create a model with a reasoner set based on the chosen reasoning level.
*
* @param reasoningLevel
* The reasoning level for this model
*
* @return The created ontology model
*/
private OntModel createModel(String reasoningLevel) {
OntModel model;
int reasoningLevelIndex;
model = null;
reasoningLevelIndex = getReasoningLevelIndex(reasoningLevel);
if (reasoningLevelIndex == 0) { // None
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
} else if (reasoningLevelIndex == 1) { // RDFS
model = ModelFactory
.createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF);
} else if (reasoningLevelIndex == 2) { // OWL
final Reasoner reasoner = PelletReasonerFactory.theInstance().create();
final Model infModel = ModelFactory.createInfModel(reasoner,
ModelFactory.createDefaultModel());
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,
infModel);
}
return model;
}
开发者ID:DaveRead,项目名称:BasicQuery,代码行数:32,代码来源:RdbToRdf.java
示例2: findAllLabels
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
public LinkedList<SemanticConcept> findAllLabels(String ontologyUri,String rootClass){
LinkedList<SemanticConcept> list = new LinkedList<>();
try{
//Create a reasoner
OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
//Create new URL of ontology
URL url = new URL(ontologyUri);
//Create model for the ontology
model.read(url.openStream(),null);
//Load model to the reasoner
model.prepare();
//Compute the classification tree
((PelletInfGraph) model.getGraph()).getKB().classify();
//Set OWL root element (e.g., it could be thing: model.getOntClass(OWL.Thing.getURI()))
OntClass owlRoot = model.getOntClass(rootClass);
SemanticConcept sc = new SemanticConcept();
sc.setUrl(owlRoot.getURI());
sc.setName("");
sc.setSemanticSimilarity("");
list.add(sc);
//For each subclass (direct or indirect)
for (Iterator it = owlRoot.listSubClasses(false); it.hasNext();) {
OntClass subclass = (OntClass) it.next();
//If subclass is not anonymous
if (!subclass.isAnon()) {
//If subclass is not nothing
if(!subclass.getURI().equals(com.hp.hpl.jena.vocabulary.OWL.Nothing.getURI())){
sc = new SemanticConcept();
sc.setUrl(subclass.getURI());
sc.setName("");
sc.setSemanticSimilarity("");
list.add(sc);
}
}
}
}catch(IOException ex){}
return list;
}
开发者ID:usplssb,项目名称:SemanticSCo,代码行数:57,代码来源:SemanticReasoner.java
示例3: readModel
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
protected OntModel readModel() {
Reasoner reasoner = PelletReasonerFactory.theInstance().create();
Model infModel = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
OntModel ontModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, infModel);
ontModel.read(getClass().getResourceAsStream("/" + modelBase), null, TTL);
return ontModel;
}
开发者ID:mehmandarov,项目名称:zebra-puzzle-workshop,代码行数:8,代码来源:Exercise4.java
示例4: readModel
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
protected OntModel readModel(String modelInput) {
Reasoner reasoner = PelletReasonerFactory.theInstance().create();
Model infModel = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
OntModel ontModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, infModel);
ontModel.read(getClass().getResourceAsStream("/" + modelInput), null, TTL);
return ontModel;
}
开发者ID:mehmandarov,项目名称:zebra-puzzle-workshop,代码行数:8,代码来源:Exercise32.java
示例5: run
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
@Override
public void run() {
final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
for (final URL u : ontologyURLs)
try {
final String uri = u.toExternalForm();
out.println("Loading " + uri);
if (uri.endsWith(".ttl")){
out.println("recognized turtle");
model.read(uri, "http://example.org", "TURTLE");
} else
model.read(u.toExternalForm());
out.println("Loaded " + uri);
} catch (Exception e) {
model.close();
handler.error(new OntologyDownloadError(u, e));
return;
}
out.println("Consistency check started");
final ValidityReport report = model.validate();
if (report.isValid()){
out.println("Consistency check succesful complete");
handler.complete(new JenaQueryEngine(model));
}
else {
out.println("Consistency check complete with errors");
model.close();
handler.error(new InconsistenOntologyException());
}
}
开发者ID:opendatahacklab,项目名称:semanticoctopus,代码行数:31,代码来源:JenaPelletSeqDownloadTask.java
示例6: run
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的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
示例7: closure
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的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
示例8: Reasoner
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
/**
* @param model the RDF model containing the CarbonDB ontology.
*/
public Reasoner (Model model) {
this.model = model;
jenaReasoner = PelletReasonerFactory.theInstance().create();
}
开发者ID:myclabs,项目名称:CarbonDB-reasoner,代码行数:8,代码来源:Reasoner.java
示例9: findAllInputs
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
public Tree findAllInputs(String ontologyUri,String rootClass){
OntModel model;
try{
//Create a reasoner
model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
//Create new URL of ontology
URL url = new URL(ontologyUri);
//Create model for the ontology
model.read(url.openStream(),null);
//Load model to the reasoner
model.prepare();
//Compute the classification tree
((PelletInfGraph) model.getGraph()).getKB().classify();
//Set OWL root element (e.g., it could be thing: model.getOntClass(OWL.Thing.getURI()))
OntClass owlRoot = model.getOntClass(rootClass);
//Create new tree element
Tree tree = new Tree();
//Recursively create a tree starting from root
Node rootNode = this.createTree(owlRoot);
//Set root node of tree
tree.setRoot(rootNode);
return tree;
}catch(IOException ex){
return null;
}
}
开发者ID:usplssb,项目名称:SemanticSCo,代码行数:41,代码来源:SemanticReasoner.java
示例10: OWLJavaFileGenerator
import org.mindswap.pellet.jena.PelletReasonerFactory; //导入依赖的package包/类
/**
* Initializes the generator with an Anno4j instance which connected repository
* will receive the ontology information (including inferred statements) after a call
* to {@link #build()} or {@link #generateJavaFiles(OntGenerationConfig, File)}.
* @param anno4j The Anno4j instance that will receive ontology information.
*/
public OWLJavaFileGenerator(Anno4j anno4j) {
this.anno4j = anno4j;
model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
}
开发者ID:anno4j,项目名称:anno4j,代码行数:12,代码来源:OWLJavaFileGenerator.java
注:本文中的org.mindswap.pellet.jena.PelletReasonerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论