I am using Jena and I want to update the new ontology into my tdb. For example. I have 100 rows in my ontology , after I add some rules and run the reasoner, there are 105 rows now. And I need to update these 5 additional rows in my tdb. How can I get this done ?
I try to google it and I found two ways. One is using sparql to update , another is truncating the tdb and add the new model into it.
Is there any other better solution?
Thanks you
--
code
void after_reasoner(Model m) {
String yago = "http://yago-knowledge.org/resource/";
Reasoner reasoner = new GenericRuleReasoner(
Rule.rulesFromURL("file:./rules/act.rule"));
InfModel inf1 = ModelFactory.createInfModel(reasoner, m);
PrintUtil.registerPrefix("yago", "http://yago-knowledge.org/resource/");
}
So again , my problem is how to deal with the new "infmodel" to my tdb. I want to update only new fact into it.
Here is my method to get model from tdb.
Model tdb_write_return() {
String directory = "./tdb";
Dataset dataset = TDBFactory.createDataset(directory);
dataset.begin(ReadWrite.WRITE);
String ns = "http://www.darrell.com.tw/ontologies/";
Model model = dataset.getNamedModel(ns);
dataset.commit();
dataset.end();
dataset.close();
return model;
}