本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ModelFactory.createInfModel方法的典型用法代碼示例。如果您正苦於以下問題:Java ModelFactory.createInfModel方法的具體用法?Java ModelFactory.createInfModel怎麽用?Java ModelFactory.createInfModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.ModelFactory
的用法示例。
在下文中一共展示了ModelFactory.createInfModel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: inferClassRelations_OLD
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
@Deprecated
public static boolean inferClassRelations_OLD(Model classModel) {
InputStream is = AbstractNIFParser.class.getClassLoader()
.getResourceAsStream(TYPE_INFERENCE_RULES);
List<String> lines;
try {
lines = IOUtils.readLines(is);
} catch (IOException e) {
LOGGER.error("Couldn't load type inferencer rules from resource \""
+ TYPE_INFERENCE_RULES
+ "\". Working on the standard model.", e);
return false;
}
IOUtils.closeQuietly(is);
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line);
}
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(sb
.toString()));
InfModel infModel = ModelFactory.createInfModel(reasoner, classModel);
classModel.add(infModel);
return true;
}
示例2: subprojectsSellers
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static void subprojectsSellers() {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectSellersService sub = (SubProjectSellersService) ctx.getBean("subProjectSellersServiceImpl");
List<SubProjectSellers> subProjectSeller = sub.getSubProjectSellers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
for (SubProjectSellers subProjectSeller1 : subProjectSeller) {
Resource instanceSeller = infModel.createResource(OntologySpecification.instancePrefix
+ "Organization/" + subProjectSeller1.getSellerId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix
+ "Subproject/" + subProjectSeller1.getOps() + "/" + subProjectSeller1.getSubProjectId());
infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource);
infModel.add(instanceSeller, RDF.type, OntologySpecification.businessResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.subProjectResource);
instanceSubProject.addProperty(OntologySpecification.seller, instanceSeller);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/subProjectSellersEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例3: espaSellers
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static void espaSellers() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SellersService sellers = (SellersService) ctx.getBean("sellersServiceImpl");
List<Sellers> seller = sellers.getSellers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("vcard", OntologySpecification.vcardPrefix);
for (Sellers seller1 : seller) {
Resource instanceSeller = infModel.createResource(OntologySpecification.instancePrefix + "Organization/" + seller1.getId());
infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource);
instanceSeller.addProperty(OntologySpecification.name, seller1.getEponimia(), XSDDatatype.XSDstring);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/sellersEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例4: readModel
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的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;
}
示例5: readModel
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的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;
}
示例6: testIsEmpty
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
* Test if an inference model produce any results
*
*/
@Test
public void testIsEmpty() throws Exception {
boolean res = false;
InfModel inf = ModelFactory.createInfModel(this.myReasoner, this.instances);
if (!inf.isEmpty()) {
/// Inference is OK. Maybe we have new statements
res = true;
}
assertTrue(res);
}
示例7: testIsConsistent
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
* Test if the new Inference Model is consistent.
*
*/
@Test
public void testIsConsistent() throws Exception {
boolean res = false;
InfModel inf = ModelFactory.createInfModel(this.myReasoner, this.instances);
if (!inf.isEmpty()) {
ValidityReport validity = inf.validate();
if (validity.isValid()) {
// Our inference has been validated and we can say that is consistent based on new rules.
res = true;
}
}
assertTrue(res);
}
示例8: testNewStatements
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
* Test if there are new statements based on loaded rule in the Reasoner
*
*/
@Test
public void testNewStatements() throws Exception {
boolean res = false;
InfModel inf = ModelFactory.createInfModel(this.myReasoner, this.instances);
if (!inf.isEmpty()) {
// It returns True if empty
res = !inf.getDeductionsModel().isEmpty();
}
assertTrue(res);
}
示例9: bindJenaRuleReasoner
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
private static void bindJenaRuleReasoner() {
final String rule = "[gmailFriend: (?person <http://xmlns.com/foaf/0.1/mbox_sha1sum> ?email), strConcat(?email, ?lit), regex(?lit, '(.*gmail.com)')"
+ "-> (?person " + RDF_TYPE_INSPARQL + " <http://www.people.com#GmailPerson>)]";
Reasoner ruleReasoner = new GenericRuleReasoner(Rule.parseRules(rule));
ruleReasoner = ruleReasoner.bindSchema(schema);
inferredModel = ModelFactory.createInfModel(ruleReasoner, friendsModel);
}
示例10: applyReasoning
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
void applyReasoning(Reasoning r) {
switch(r) {
case rdfs:
this.jenaModel = ModelFactory.createRDFSModel(this.jenaModel);
break;
case owl:
this.jenaModel = ModelFactory.createInfModel(ReasonerRegistry.getOWLReasoner(),
this.jenaModel);
break;
default:
break;
}
}
示例11: espaSubprojects
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static void espaSubprojects() throws ParseException {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectsService sub = (SubProjectsService) ctx.getBean("subProjectsServiceImpl");
List<SubProjects> subProject = sub.getSubProjects();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("dcterms", OntologySpecification.dctermsPrefix);
//number format
DecimalFormat df = new DecimalFormat("0.00");
for (SubProjects subProject1 : subProject) {
Resource instanceCurrency = infModel.createResource("http://linkedeconomy.org/resource/Currency/EUR");
Resource instanceBudgetUps = infModel.createResource(OntologySpecification.instancePrefix
+ "UnitPriceSpecification/BudgetItem/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceBudget = infModel.createResource(OntologySpecification.instancePrefix + "BudgetItem/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix + "Subproject/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix
+ "Subsidy/" + subProject1.getOps());
DateFormat dfDate = new SimpleDateFormat("dd/MM/yyyy");
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
java.util.Date stDateStarts;
java.util.Date stDateEnds;
stDateStarts = dfDate.parse(subProject1.getStart());
stDateEnds = dfDate.parse(subProject1.getFinish());
String startDate = df2.format(stDateStarts);
String endDate = df2.format(stDateEnds);
infModel.add(instanceProject, RDF.type, OntologySpecification.projectResource);
infModel.add(instanceBudgetUps, RDF.type, OntologySpecification.priceSpecificationResource);
infModel.add(instanceBudget, RDF.type, OntologySpecification.budgetResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.subProjectResource);
instanceProject.addProperty(OntologySpecification.hasRelatedProject, instanceSubProject);
instanceSubProject.addProperty(OntologySpecification.hasRelatedBudgetItem, instanceBudget);
instanceBudget.addProperty(OntologySpecification.price, instanceBudgetUps);
instanceBudgetUps.addProperty(OntologySpecification.hasCurrencyValue, df.format(subProject1.getBudget()), XSDDatatype.XSDfloat);
instanceBudgetUps.addProperty(OntologySpecification.valueAddedTaxIncluded, "true", XSDDatatype.XSDboolean);
instanceBudgetUps.addProperty(OntologySpecification.hasCurrency, instanceCurrency);
instanceSubProject.addProperty(OntologySpecification.startDate, startDate, XSDDatatype.XSDdateTime);
instanceSubProject.addProperty(OntologySpecification.endDate, endDate, XSDDatatype.XSDdateTime);
instanceSubProject.addProperty(OntologySpecification.title, String.valueOf(subProject1.getTitle()), "el");
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/subProjectEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例12: espaBuyers
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static void espaBuyers() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
BuyersService buyers = (BuyersService) ctx.getBean("buyersServiceImpl");
List<Buyers> buyer = buyers.getBuyers();
List<Buyer> projectBuyer = buyers.getProjectBuyers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("vcard", OntologySpecification.vcardPrefix);
for (Buyer projectBuyer1 : projectBuyer) {
Resource instanceBuyer = infModel.createResource(OntologySpecification.instancePrefix + "Organization/" + projectBuyer1.getBuyerId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix + "Subsidy/" + projectBuyer1.getOps());
infModel.add(instanceBuyer, RDF.type, OntologySpecification.organizationResource);
infModel.add(instanceProject, RDF.type, OntologySpecification.subsidyResource);
instanceProject.addProperty(OntologySpecification.beneficiary, instanceBuyer);
instanceBuyer.addProperty(OntologySpecification.name, String.valueOf(projectBuyer1.getEponimia()), XSDDatatype.XSDstring);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/buyersEspa.rdf");
// /home/svaf/buyersEspa.rdf
// /Users/giovaf/Documents/yds_pilot1/espa_tests/06-01-2016_output/buyersEspa.rdf
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例13: exportRfd
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
*
* Implementation Of Subproject Service layer
* and transformation of Database data to RDF
*
* @throws java.text.ParseException
* @throws java.io.UnsupportedEncodingException
* @throws java.io.FileNotFoundException
*/
public static void exportRfd() throws ParseException, UnsupportedEncodingException, FileNotFoundException, IOException {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectsService sub = (SubProjectsService) ctx.getBean("subProjectsServiceImpl");
List<SubprojectsProjects> subProject = sub.getInfoSubproject();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("dcterms", OntologySpecification.dctermsPrefix);
//number format
DecimalFormat df = new DecimalFormat("0.00");
for (SubprojectsProjects subProject1 : subProject) {
Resource instanceCurrency = infModel.createResource("http://linkedeconomy.org/resource/Currency/EUR");
Resource instanceUps = infModel.createResource(OntologySpecification.instancePrefix
+ "UnitPriceSpecification/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceBudget = infModel.createResource(OntologySpecification.instancePrefix + "BudgetItem/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix + "Contract/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix
+ "PublicWork/" + subProject1.getOps());
infModel.add(instanceUps, RDF.type, OntologySpecification.priceSpecificationResource);
infModel.add(instanceBudget, RDF.type, OntologySpecification.budgetResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.contractResource);
instanceProject.addProperty(OntologySpecification.hasRelatedContract, instanceSubProject);
instanceSubProject.addProperty(OntologySpecification.price, instanceUps);
instanceUps.addProperty(OntologySpecification.hasCurrencyValue, df.format(subProject1.getBudget()), XSDDatatype.XSDfloat);
instanceUps.addProperty(OntologySpecification.valueAddedTaxIncluded, "true", XSDDatatype.XSDboolean);
instanceUps.addProperty(OntologySpecification.hasCurrency, instanceCurrency);
if (subProject1.getStart() != null) {
instanceSubProject.addProperty(OntologySpecification.pcStartDate, subProject1.getStart().replace("/", "-"), XSDDatatype.XSDdate);
}
if (subProject1.getFinish() != null) {
instanceSubProject.addProperty(OntologySpecification.actualEndDate, subProject1.getFinish().replace("/", "-"), XSDDatatype.XSDdate);
}
instanceSubProject.addProperty(OntologySpecification.title, String.valueOf(subProject1.getTitle()), "el");
}
try {
FileOutputStream fout = new FileOutputStream(
CommonVariables.serverPath + "subProjectEspa_"+ CommonVariables.currentDate + ".rdf");
model.write(fout);
fout.close();
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例14: testUploadedData
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
* Test is new infered data is uploaded into Fuseki server. To do this it is needed.
*
* --> A Fuseki server runing in localhost int port 3030
* ---> A city4age dataset created into Fuseki Server
*
*/
@Test
public void testUploadedData() throws Exception {
boolean res = false;
InfModel inf = ModelFactory.createInfModel(this.myReasoner, this.instances);
final OntModel finalResult = ModelFactory.createOntologyModel();
finalResult.add(this.instances);
finalResult.add(inf.getDeductionsModel());
// Set prefix map
finalResult.setNsPrefixes(this.instances.getNsPrefixMap());
finalResult.setNsPrefixes(inf.getDeductionsModel().getNsPrefixMap());
// Converting final result to string and writ it
StringWriter out = new StringWriter();
finalResult.write(out, "RDF/XML");
String result = out.toString();
// Launch curl to upload or current knowledge into Fuseki
ProcessBuilder p = new ProcessBuilder("curl", "-k", "-X", "POST", "--header", "Content-Type: application/rdf+xml",
"-d", result, "http://localhost:3030/city4age/data");
try {
System.out.println("Uploading new Knowledge to Fuseki......................");
System.out.println("");
// Execute our command
final Process shell = p.start();
// catch output and see if all is ok
BufferedReader reader =
new BufferedReader(new InputStreamReader(shell.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = null;
while ( (line = reader.readLine()) != null) {
builder.append(line);
builder.append(System.getProperty("line.separator"));
}
String output = builder.toString();
if (output.length() > 0 && output.contains("count")) {
// We have good response from the server
res = true;
}else {
System.err.println("Some error happened. Is Fuseki activated?");
}
}catch (IOException e) {
e.printStackTrace();
}
// Asserting the result
assertTrue(res);
}
示例15: bindReasoner
import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
private static void bindReasoner() {
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(schema);// tbox
inferredModel = ModelFactory.createInfModel(reasoner, friendsModel);// abox
}