当前位置: 首页>>代码示例>>Java>>正文


Java Reasoner类代码示例

本文整理汇总了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;
}
 
开发者ID:DaveRead,项目名称:BasicQuery,代码行数:32,代码来源:RdbToRdf.java

示例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;
   }
 
开发者ID:dice-group,项目名称:Cetus,代码行数:26,代码来源:ClassModelCreator.java

示例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;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:27,代码来源:SimpleSubClassInferencerFactory.java

示例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" );
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:24,代码来源:SparqlQueryWithPropertySubclass.java

示例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" );		
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:24,代码来源:RDFSLabels.java

示例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" );		
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:24,代码来源:TermReconcilation_UnionPattern.java

示例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" );		
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:24,代码来源:RDFS_CommonProperty.java

示例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" );		
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:23,代码来源:TermReconciliation_Subclass.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:21,代码来源:OWL_TransitiveProperty.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:21,代码来源:OWLMain30_WithoutSameAs.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:24,代码来源:OWLMain30_WithSameAs.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:21,代码来源:OWL_WeirdInference.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:21,代码来源:OWLSymmetricProperty.java

示例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" );		
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:21,代码来源:AnotherInverseOfProperty.java

示例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());
        }
    }
 
开发者ID:YourDataStories,项目名称:harvesters,代码行数:37,代码来源:SubprojectsSellersImpl.java


注:本文中的com.hp.hpl.jena.reasoner.Reasoner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。