本文整理汇总了Java中com.hp.hpl.jena.reasoner.Reasoner类的典型用法代码示例。如果您正苦于以下问题:Java Reasoner类的具体用法?Java Reasoner怎么用?Java Reasoner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Reasoner类属于com.hp.hpl.jena.reasoner包,在下文中一共展示了Reasoner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModel
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的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;
}
示例2: inferClassRelations_OLD
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的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;
}
示例3: createInferencer
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static SimpleSubClassInferencer createInferencer(Model classModel) {
String resourceName = GerbilConfiguration.getInstance().getString(SUB_CLASS_INFERENCER_RULE_FILE_KEY);
if (resourceName == null) {
LOGGER.error("Couldn't load subclass inferencer rules resource name from properties. Returning null.");
return null;
}
InputStream is = RootConfig.class.getClassLoader().getResourceAsStream(resourceName);
List<String> lines;
try {
lines = IOUtils.readLines(is);
} catch (IOException e) {
LOGGER.error("Couldn't load subclass inferencer rules from resource \"" + resourceName
+ "\". Returning null.", e);
return null;
}
IOUtils.closeQuietly(is);
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line);
}
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(sb.toString()));
InfModel inf = ModelFactory.createInfModel(reasoner, classModel);
SimpleSubClassInferencer inferencer = new SimpleSubClassInferencer(inf);
return inferencer;
}
示例4: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex5-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#worksFor> ?z }" ;
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n----------\ndone" );
}
示例5: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex13-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.w3.org/2000/01/rdf-schema#label> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例6: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex12-data2.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x WHERE { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.org/example#Investigator> }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例7: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex17-data2.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://cal.example.com/cal#nextDeparture> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例8: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex12-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x WHERE { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.org/example#Analyst> }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例9: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex22-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#hasAncestor> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例10: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex30-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?facility ?location WHERE { ?p <http://www.example.org/example#manufactureLocation> ?location . ?p <http://mfg.example.org/mfg#facility> ?facility . }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n-------DONE--------\n" );
}
示例11: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex30-data.ttl");
Model sameAsData = FileManager.get().loadModel( "file:data/input/turtle/ex30-sameas.ttl" );
data.add( sameAsData );
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?facility ?location WHERE { ?p <http://www.example.org/example#manufactureLocation> ?location . ?p <http://mfg.example.org/mfg#facility> ?facility . }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n-------DONE--------\n" );
}
示例12: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex19-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#hasPossession> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例13: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex21-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#married> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例14: main
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex20-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.w3.org/2000/01/rdf-schema#subclassOf> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例15: subprojectsSellers
import com.hp.hpl.jena.reasoner.Reasoner; //导入依赖的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());
}
}