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


Java Reasoner.bindSchema方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.reasoner.Reasoner.bindSchema方法的典型用法代码示例。如果您正苦于以下问题:Java Reasoner.bindSchema方法的具体用法?Java Reasoner.bindSchema怎么用?Java Reasoner.bindSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.reasoner.Reasoner的用法示例。


在下文中一共展示了Reasoner.bindSchema方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindJenaRuleReasoner

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的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);
}
 
开发者ID:zhoujiagen,项目名称:Jena-Based-Semantic-Web-Tutorial,代码行数:8,代码来源:HelloSemanticWeb.java

示例2: bindReasoner

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
private static void bindReasoner() {
	Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
	reasoner = reasoner.bindSchema(schema);// tbox
	inferredModel = ModelFactory.createInfModel(reasoner, friendsModel);// abox
}
 
开发者ID:zhoujiagen,项目名称:Jena-Based-Semantic-Web-Tutorial,代码行数:6,代码来源:HelloSemanticWeb.java

示例3: main

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
public static void main(String args[])
{
	String filename = "example6.rdf";

	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);

	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);

	// ** TASK 7.1: List all individuals of "Person" **
	System.out.println("\nTASK 7.1 - List all individuals of Person\n");
	OntClass person = model.getOntClass(ns+"Person");
	ExtendedIterator<? extends OntResource> itr = person.listInstances();
	while(itr.hasNext()){
		Individual persons = (Individual) itr.next();
		System.out.println("Person : " + persons);	
	}
	// ** TASK 7.2: List all subclasses of "Person" **
	System.out.println("\nTASK 7.2 - List all subclasses of Person\n");
	itr = person.listSubClasses(false);
	while (itr.hasNext()) {
		OntClass ontClass = (OntClass) itr.next();
		System.out.println("Subclass : " + ontClass);
	}

	// ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. ** 
	// ** TIP: you need some inference... **
	System.out.println("\nTASK 7.3 - Make the necessary changes to get as well indirect instances and subclasses\n");
	Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
	reasoner = reasoner.bindSchema(model);
	reasoner.setDerivationLogging(true);
	InfModel inf = ModelFactory.createInfModel(reasoner, model);
	StmtIterator i = inf.listStatements(person, null, (RDFNode) null);
	while(i.hasNext()){
		Statement s = i.nextStatement();
		System.out.println("Statement: \n" + s.asTriple()); //turtle format
	}
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:46,代码来源:Task07_Nestor_Lopez.java

示例4: main

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
public static void main(String args[]) {
       String filename = "rdf examples" + File.separator + "example6.rdf";

       // Create an empty model
       OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);

       // Use the FileManager to find the input file
       InputStream in = FileManager.get().open(filename);

       if (in == null) {
           throw new IllegalArgumentException("File: " + filename + " not found");
       }

       // Read the RDF/XML file
       model.read(in, null);

       ExtendedIterator<? extends OntResource> it; // "? extends OntResource" Java go home you are drunk.
       OntClass person = model.getOntClass(ns + "Person");
       
       // ** TASK 7.1: List all individuals of "Person" **
       System.out.println("Person instances: ");
       it = person.listInstances(); 

       while (it.hasNext()) {
           System.out.println(it.next());
       }

// ** TASK 7.2: List all subclasses of "Person" **
       System.out.println("Person subclasses: ");
       it = person.listSubClasses();
       
       while (it.hasNext()) {
           System.out.println(it.next());
       }

// ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. TIP: you need some inference... **
       Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
       reasoner = reasoner.bindSchema(model);
       
       OntModelSpec ontModelSpec = OntModelSpec.RDFS_MEM;
       ontModelSpec.setReasoner(reasoner);
       
       OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec, model);
       OntClass infPerson = ontModel.getOntClass(ns + "Person");
       
       System.out.println("Person instances: ");
       it = infPerson.listInstances(); 

       while (it.hasNext()) {
           System.out.println(it.next());
       }

       System.out.println("Person subclasses: ");
       it = infPerson.listSubClasses();
       
       while (it.hasNext()) {
           System.out.println(it.next());
       }
   }
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:60,代码来源:Task07_skgsergio.java

示例5: main

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
public static void main(String args[])
{
	String filename = "C:\\Users\\MerY\\201409\\WebLinked_SematicData\\src\\Assigment3\\example6.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	
	// ** TASK 7.1: List all individuals of "Person" **
	System.out.println("7.1");
	OntClass IndvPerson = model.getOntClass(ns + "Person");
    ExtendedIterator<Individual> personIter = model.listIndividuals(IndvPerson);
       while (personIter.hasNext()) {
           Individual indiv = personIter.next();
           System.out.println(indiv.getURI()+"\n");
       }

	
	// ** TASK 7.2: List all subclasses of "Person" **
       System.out.println("7.2");
       ExtendedIterator<OntClass> subcPerson = IndvPerson.listSubClasses();
       while (subcPerson.hasNext()) {
           OntClass subclass = subcPerson.next();
           System.out.println(subclass.getURI()+"\n");
       }

	
	
	// ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. TIP: you need some inference... **
       System.out.println("7.3");
       Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
       reasoner = reasoner.bindSchema(model);

       OntModelSpec ontol = OntModelSpec.RDFS_MEM;
       ontol.setReasoner(reasoner);

       OntModel ontModel = ModelFactory.createOntologyModel(ontol, model);
       OntClass infer = ontModel.getOntClass(ns + "Person");
       
       ExtendedIterator<? extends OntResource> iterator = infer.listInstances();
       ExtendedIterator<OntClass> iterPerson = infer.listSubClasses();
       
       System.out.println("Indirect instances: ");

       while (iterator.hasNext()) {
           System.out.println(iterator.next());
       }
       
       System.out.println("Subclasses: ");

       while (iterPerson.hasNext()) {
           System.out.println(iterPerson.next());
       }

}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:65,代码来源:Task07_MariaDeMarcos.java

示例6: main

import com.hp.hpl.jena.reasoner.Reasoner; //导入方法依赖的package包/类
public static void main(String args[]) {
    String filename = "/home/alex/GitHub/Curso2014-2015/Assignment3/rdf examples/example6.rdf";

    // Create an empty model
    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);

    // Use the FileManager to find the input file
    InputStream in = FileManager.get().open(filename);

    if (in == null)
        throw new IllegalArgumentException("File: " + filename + " not found");

    // Read the RDF/XML file
    model.read(in, null);


    // ** TASK 7.1: List all individuals of "Person" **
    OntClass person = model.getOntClass(ns + "Person");
    ExtendedIterator<Individual> personIter = model.listIndividuals(person);
    while (personIter.hasNext()) {
        Individual indiv = personIter.next();
        System.out.println("Individual uri = " + indiv.getURI());
    }

    // ** TASK 7.2: List all subclasses of "Person" **
    ExtendedIterator<OntClass> personsubclasses = person.listSubClasses();
    while (personsubclasses.hasNext()) {
        OntClass subclass = personsubclasses.next();
        System.out.println("Subclass uri = " + subclass.getURI());
    }


    // ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. TIP: you need some iRnference... **

    Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
    reasoner = reasoner.bindSchema(model);

    OntModelSpec ontol = OntModelSpec.RDFS_MEM;
    ontol.setReasoner(reasoner);

    OntModel ontModel = ModelFactory.createOntologyModel(ontol, model);

    OntClass infer = ontModel.getOntClass(ns + "Person");

    System.out.println("Instances of person class: ");

    ExtendedIterator<? extends OntResource> iter = infer.listInstances();

    while (iter.hasNext()) {
        System.out.println(iter.next());
    }

    ExtendedIterator<OntClass> iterPerson = infer.listSubClasses();

    System.out.println("Subclasses of person: ");

    while (iterPerson.hasNext()) {
        System.out.println(iterPerson.next());
    }

}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:62,代码来源:Task07_baraalex.java


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