本文整理汇总了Java中org.apache.jena.rdf.model.ModelFactory.createInfModel方法的典型用法代码示例。如果您正苦于以下问题:Java ModelFactory.createInfModel方法的具体用法?Java ModelFactory.createInfModel怎么用?Java ModelFactory.createInfModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.rdf.model.ModelFactory
的用法示例。
在下文中一共展示了ModelFactory.createInfModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expand
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public static void expand() throws IOException {
boolean combined = false ;
String DIR = "testing/Inf" ;
String DATA_FILE = "data.ttl" ;
String VOCAB_FILE = "vocab.ttl" ;
String RULES_FILE = DIR+"/rdfs-min.rules" ;
Model vocab = RDFDataMgr.loadModel(VOCAB_FILE) ;
Model data = RDFDataMgr.loadModel(DATA_FILE) ;
String rules = FileUtils.readWholeFileAsUTF8(RULES_FILE) ;
rules = rules.replaceAll("#[^\\n]*", "") ;
InferenceSetupRDFS setup = new InferenceSetupRDFS(vocab, combined) ;
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
InfModel m = ModelFactory.createInfModel(reasoner, vocab, data);
// Expansion Graph
Graph graphExpanded = Factory.createDefaultGraph() ;
StreamRDF stream = StreamRDFLib.graph(graphExpanded) ;
// Apply inferences.
stream = new InferenceProcessorStreamRDF(stream, setup) ;
sendToStream(data.getGraph(), stream) ;
RDFDataMgr.write(System.out, graphExpanded, Lang.TTL) ;
}
示例2: checkConsistency
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public boolean checkConsistency(Resource cls, Model model) {
Model temp = ModelFactory.createDefaultModel();
temp.add(this.model);
if (infModel==null) infModel = ModelFactory.createInfModel(reasoner,this.model);
// merge the models eg. optimization of infModel.add(model);
// if the class is anonymous add it separately
Map<RDFNode,RDFNode> visited = new HashMap<RDFNode,RDFNode>();
if (cls!=null && cls.isAnon()) mergeDescription(infModel.createResource(), cls, false, visited);
mergeModel(model,false,visited);
boolean valid = infModel.validate().isValid();
if (!valid) {
// restore the old state
this.model.removeAll().add(temp);
infModel.rebind();
}
else {
// mark known classes as OK
Resource ok = infModel.getResource(Gloze.OK);
for (ResIterator ri = this.model.listSubjectsWithProperty(RDF.type, OWL.Class); ri.hasNext(); )
ri.nextResource().addProperty(RDF.type, ok);
}
return valid;
}
示例3: plain
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public static void plain(String...argv) throws IOException {
String DIR = "testing/Inf" ;
// String DATA_FILE = DIR+"/rdfs-data.ttl" ;
// String VOCAB_FILE = DIR+"/rdfs-vocab.ttl" ;
// String RULES_FILE = DIR+"/rdfs-min.rules" ;
String DATA_FILE = "data.ttl" ;
String VOCAB_FILE = "vocab.ttl" ;
String RULES_FILE = DIR+"/rdfs-min.rules" ;
Model vocab = RDFDataMgr.loadModel(VOCAB_FILE) ;
Model data = RDFDataMgr.loadModel(DATA_FILE) ;
String rules = FileUtils.readWholeFileAsUTF8(RULES_FILE) ;
rules = rules.replaceAll("#[^\\n]*", "") ;
InferenceSetupRDFS setup = new InferenceSetupRDFS(vocab, false) ;
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
InfModel m = ModelFactory.createInfModel(reasoner, vocab, data);
inf = m.getGraph() ;
g_rdfs2 = new GraphRDFS(setup, data.getGraph()) ;
//g_rdfs3 = new GraphRDFS3(setup, data.getGraph()) ;
//test(null, null, node("T2")) ;
test(node("T"), null, null ) ;
// Expansion
//InferenceProcessorRDFS proc = new InferenceProcessorRDFS(setup) ;
}
示例4: createRulesGraph
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
/** Create a Jena-rules backed graph */
protected static Graph createRulesGraph(Model data, Model vocab, String rulesFile) {
try {
String rules = FileUtils.readWholeFileAsUTF8(rulesFile) ;
rules = rules.replaceAll("#[^\\n]*", "") ;
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules)) ;
// Model m = ModelFactory.createInfModel(reasoner, data);
/** Rules way */
InfModel m = ModelFactory.createInfModel(reasoner, vocab, data) ;
return m.getGraph() ;
}
catch (IOException ex) { IO.exception(ex) ; return null ; }
}
示例5: read
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Override
public void read(final String modelPath) throws IOException {
final Model defaultModel = ModelFactory.createDefaultModel();
defaultModel.read(modelPath);
// run inferencing if required
if (inferencing) {
final Reasoner reasoner = ReasonerRegistry.getRDFSSimpleReasoner();
model = ModelFactory.createInfModel(reasoner, defaultModel);
} else {
model = defaultModel;
}
}
示例6: setReasoner
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public void setReasoner(Reasoner reasoner) {
this.reasoner = reasoner;
infModel = ModelFactory.createInfModel(reasoner,this.model); }