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


Java OWLReasonerFactory.createReasoner方法代码示例

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


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

示例1: testMergeSpecies

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
@Test
public void testMergeSpecies() throws Exception {
	ParserWrapper p = new ParserWrapper();
	OWLOntology owlOntology = p.parse(getResourceIRIString("speciesMergeTest.obo"));
	OWLGraphWrapper graph = new OWLGraphWrapper(owlOntology);
	OWLReasonerFactory rf = new ElkReasonerFactory();
	OWLReasoner reasoner = rf.createReasoner(graph.getSourceOntology());
	SpeciesMergeUtil smu = new SpeciesMergeUtil(graph);
	smu.viewProperty = graph.getOWLObjectPropertyByIdentifier("BFO:0000050");
	smu.taxClass = graph.getOWLClassByIdentifier("T:1");
	smu.reasoner = reasoner;
	smu.suffix = "coelocanth";
	smu.merge();
	
	p.saveOWL(smu.ont, new OBODocumentFormat(), "target/speciesMergeOut.obo");
	
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:18,代码来源:SpeciesMergeUtilTest.java

示例2: beforeClass

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {

	// Setup environment.
	ParserWrapper pw = new ParserWrapper();

	//NOTE: Yes, the GO here is unnecessary, but we're trying to also catch a certain behavior
	// where auxilery ontologies are not caught. The best wat to do that here is to load ECO
	// second and then do the merge.
	OWLOntology ont_main = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
	OWLOntology ont_scnd = pw.parse(getResourceIRIString("eco.obo"));
	g = new OWLGraphWrapper(ont_main);
	g.addSupportOntology(ont_scnd);
	
	// NOTE: This step is necessary or things will get ignored!
	// (This cropped-up in the loader at one point.)
	for (OWLOntology ont : g.getSupportOntologySet())
		g.mergeOntology(ont);
	
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	r = reasonerFactory.createReasoner(g.getSourceOntology());
	g.setReasoner(r);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:24,代码来源:EcoToolsTest.java

示例3: main

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException {
    //register my built-in implementation
    BuiltInRegistry.instance.registerBuiltIn("urn:makub:builtIn#IRIparts", new CustomSWRLBuiltin(new IRIparts()));
    //initialize ontology and reasoner
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(DOC_URL));
    OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
    OWLDataFactory factory = manager.getOWLDataFactory();
    PrefixDocumentFormat pm = manager.getOntologyFormat(ontology).asPrefixOWLOntologyFormat();
    //print the SWRL rule
    listSWRLRules(ontology);
    //use the rule with the built-in to infer property values
    OWLNamedIndividual martin = factory.getOWLNamedIndividual(":Martin", pm);
    listAllDataPropertyValues(martin, ontology, reasoner);
}
 
开发者ID:martin-kuba,项目名称:owl2-swrl-tutorial,代码行数:17,代码来源:IndividualSWRLBuiltinTutorial.java

示例4: main

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException {
    //register my built-in
    BuiltInRegistry.instance.registerBuiltIn("urn:makub:builtIn#thisYear", new GeneralFunctionBuiltIn(new ThisYear()));
    //initialize ontology and reasoner
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(DOC_URL));
    OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
    OWLDataFactory factory = manager.getOWLDataFactory();
    PrefixDocumentFormat pm = manager.getOntologyFormat(ontology).asPrefixOWLOntologyFormat();
    //use the rule with the built-in to infer data property values
    OWLNamedIndividual martin = factory.getOWLNamedIndividual(":Martin", pm);
    listAllDataPropertyValues(martin, ontology, reasoner);

    OWLNamedIndividual ivan = factory.getOWLNamedIndividual(":Ivan", pm);
    listAllDataPropertyValues(ivan, ontology, reasoner);
}
 
开发者ID:martin-kuba,项目名称:owl2-swrl-tutorial,代码行数:18,代码来源:SWRLBuiltInsTutorial.java

示例5: DLPPINotAnalyser

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public DLPPINotAnalyser(Bpmn20ModelHandlerInterface bpmnModelHandler, PpiNotModelHandlerInterface ppinotModelHandler, OWLReasonerFactory reasonerFactory) {
    this.bpmnModelHandler = bpmnModelHandler;
    this.ppinotModelHandler = ppinotModelHandler;
    owlManager = OWLManager.createOWLOntologyManager();
    conversor = new IdOwlConversor();

    try {
        BPMN2OWLConverterInterface bpmnConverter = new BPMN2OWLConverter(BPMN_BASE_IRI, owlManager);
        bpmnOntology = bpmnConverter.convertToOwlOntology(bpmnModelHandler);
        String bpmnOntologyURI = bpmnConverter.getOntologyURI();

        PPINOT2OWLConverterInterface ppinotConverter = new PPINOT2OWLConverter(PPINOT_BASE_IRI, owlManager);
        ppinotConverter.setBpmnData(bpmnOntologyURI, bpmnModelHandler);
        ppinotOntology = ppinotConverter.convertToOwlOntology(ppinotModelHandler);
    } catch (OWLOntologyCreationException e) {
        throw new RuntimeException(e);
    }

    AnalysisOntologyBuilder builder = new AnalysisOntologyBuilder(owlManager);
    String analysisURI = PPINOT_BASE_IRI + bpmnModelHandler.getProcId() + "-analysis.owl";
    analysisOntology = builder.buildAnalysisOntology(analysisURI, ppinotOntology);

    engine = new DLQueryEngine(reasonerFactory.createReasoner(analysisOntology));

}
 
开发者ID:isa-group,项目名称:ppinot,代码行数:26,代码来源:DLPPINotAnalyser.java

示例6: main

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
/**
 * @param args
 * @throws OWLOntologyCreationException
 */
public static void main(String[] args) throws OWLOntologyCreationException {
	OWLOntologyManager man = OWLManager.createOWLOntologyManager();

	// Load your ontology.
	OWLOntology ont = man
			.loadOntologyFromOntologyDocument(new File(args[0]));
	
	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);
	
	// Precompute instances for each named class in the ontology
	reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS);

	// List representative instances for each class.
	for (OWLClass clazz : ont.getClassesInSignature()) {
		for (Node<OWLNamedIndividual> individual : reasoner.getInstances(
				clazz, true)) {
			System.out.println(clazz + "("
					+ individual.getRepresentativeElement() + ")");
		}
	}

	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:31,代码来源:RetrievingInstances.java

示例7: main

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws OWLOntologyStorageException,
		OWLOntologyCreationException {
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

	// Load your ontology
	OWLOntology ont = manager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));

	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);

	// Classify the ontology.
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	OWLDataFactory factory = manager.getOWLDataFactory();
	OWLClass subClass = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#AbsoluteShapeState"));
	OWLAxiom removed = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#ShapeState")));
	
	OWLAxiom added = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#GeneralisedStructure")));
	// Remove an existing axiom, add a new axiom
	manager.addAxiom(ont, added);
	manager.removeAxiom(ont, removed);
	// This is a buffering reasoner, so you need to flush the changes
	reasoner.flush();
	
	// Re-classify the ontology, the changes should be accommodated
	// incrementally (i.e. without re-inferring all subclass relationships)
	// You should be able to see it from the log output
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);		
	
	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:34,代码来源:IncrementalClassification.java

示例8: testImport

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
/**
 * Testing loading of ontologies that have no axioms (but possibly import
 * declarations).
 * 
 * @see <a
 *      href="http://code.google.com/p/elk-reasoner/issues/detail?id=7">Issue 7<a>
 * @throws OWLOntologyCreationException
 * @throws URISyntaxException
 */
@Test
public void testImport() throws OWLOntologyCreationException,
		URISyntaxException {

	OWLOntologyManager man = TestOWLManager.createOWLOntologyManager();

	// loading the root ontology
	OWLOntology root = loadOntology(man, "root.owl");

	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(root);

	try {
		// statistics about the root ontology
		assertEquals(root.getAxiomCount(), 0);
		// all two ontologies should be in the closure
		assertEquals(root.getImportsClosure().size(), 2);
		// all axioms from two ontologies should be in the closure
		assertEquals(getAxioms(root).size(), 0);

		// reasoner queries -- all subclasses are there
		reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
	} finally {
		reasoner.dispose();
	}

}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:38,代码来源:EmptyImportTest.java

示例9: build

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
/**
 * @param reasonerFactory
 * @throws OWLOntologyCreationException 
 */
public void build(OWLReasonerFactory reasonerFactory) throws OWLOntologyCreationException {
	buildViewOntology();
	OWLReasoner reasoner = reasonerFactory.createReasoner(assertedViewOntology);
	try {
		buildInferredViewOntology(reasoner);
	}
	finally {
		reasoner.dispose();
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:15,代码来源:PropertyViewOntologyBuilder.java

示例10: main

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(BASE_URL));
    OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();

    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
    Version v = reasoner.getReasonerVersion();
    System.out.println("reasoner "+reasoner.getReasonerName()+ " " + v.getMajor()+"."+v.getMinor()+"."+v.getPatch()+" build "+v.getBuild());

    OWLDataFactory factory = manager.getOWLDataFactory();
    OWLClass aClass = factory.getOWLClass(IRI.create(BASE_URL+"#A"));
    System.out.println("it will hang on the next line for Pellet 2.3 ...");
    NodeSet<OWLNamedIndividual> nodeSet = reasoner.getInstances(aClass, false);
    System.out.println("this is never printed");
}
 
开发者ID:martin-kuba,项目名称:owl2-swrl-tutorial,代码行数:16,代码来源:Pellet230Error.java

示例11: createReasoner

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
private OWLReasoner createReasoner(OWLOntology ont, String reasonerName, 
        OWLOntologyManager manager) {
    OWLReasonerFactory reasonerFactory = createReasonerFactory(reasonerName);
    if (reasonerFactory == null) {
        System.out.println("no such reasoner: "+reasonerName);
    }
    else {
        reasoner = reasonerFactory.createReasoner(ont);
        LOG.info("Created reasoner: "+reasoner);
    }
    return reasoner;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:13,代码来源:CommandRunner.java

示例12: init

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public boolean init() {
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	reasoner = reasonerFactory.createReasoner(getGraph().getSourceOntology());
	boolean consistent = reasoner.isConsistent();
	if (!consistent) {
		LOG.error("The ontology is not consistent. Impossible to make proper predictions.");
		if (throwExceptions) {
			throw new RuntimeException("The ontology is not consistent. Impossible to make proper predictions.");	
		}
		return false;
	}
	relevantClasses = new HashSet<OWLClass>();
	// add GO
	// biological process
	OWLClass bp = getGraph().getOWLClassByIdentifier("GO:0008150");
	addRelevant(bp, reasoner, getGraph(), relevantClasses);
	
	// molecular function
	OWLClass mf = getGraph().getOWLClassByIdentifier("GO:0003674");
	addRelevant(mf, reasoner, getGraph(), relevantClasses);
	
	// cellular component
	OWLClass cc = getGraph().getOWLClassByIdentifier("GO:0005575");
	addRelevant(cc, reasoner, getGraph(), relevantClasses);
	
	// properties
	partOf = OBOUpperVocabulary.BFO_part_of.getObjectProperty(getGraph().getDataFactory());
	occursIn = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(getGraph().getDataFactory());
	defaultProperties = Collections.unmodifiableSet(new HashSet<OWLObjectProperty>(Arrays.asList(partOf, occursIn)));
	
	if (relevantClasses.isEmpty()) {
		LOG.error("No valid classes found for fold based prediction folding.");
		if (throwExceptions) {
			throw new RuntimeException("No valid classes found for fold based prediction folding.");
		}
		return false;
	}
	return true;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:40,代码来源:FoldBasedPredictor.java

示例13: testMergeFly

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
@Test
public void testMergeFly() throws Exception {
	ParserWrapper p = new ParserWrapper();
	OWLOntology owlOntology = p.parse(getResourceIRIString("interneuron-fly.obo"));
	Set<OWLClass> clsBefore = owlOntology.getClassesInSignature();
	OWLGraphWrapper graph = new OWLGraphWrapper(owlOntology);
	OWLReasonerFactory rf = new ElkReasonerFactory();
	OWLReasoner reasoner = rf.createReasoner(graph.getSourceOntology());
	SpeciesMergeUtil smu = new SpeciesMergeUtil(graph);

	smu.viewProperty = graph.getOWLObjectPropertyByIdentifier("BFO:0000050");
	smu.taxClass = graph.getOWLClassByIdentifier("NCBITaxon:7227");
	smu.reasoner = reasoner;
	smu.suffix = "fly";
	smu.includedProperties = Collections.singleton(smu.viewProperty);
	//smu.includedProperties = Collections.singleton(graph.getOWLObjectPropertyByIdentifier("BFO:0000051"));
	smu.merge();
	
	Set<OWLClass> clsAfter = smu.ont.getClassesInSignature();
	
	LOG.info("Before: "+clsBefore.size());
	LOG.info("After: "+clsAfter.size());
	assertEquals(100, clsBefore.size());
	assertEquals(90, clsAfter.size());
	p.saveOWL(smu.ont, new OBODocumentFormat(), "target/flyMergeOut.obo");

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:SpeciesMergeUtilTest.java

示例14: GoIEPRestrictionsRule

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public GoIEPRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) {
	this.message = MESSAGE;
	this.violationType = ViolationType.Warning;
	
	evidences = eco.getAllValidEvidenceIds("IEP", true);
	
	classSubSet = new HashSet<String>();
	
	OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0008150");
	OWLReasonerFactory factory = new ElkReasonerFactory();
	OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology());
	try {
		NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false);
		for(OWLClass cls : nodeSet.getFlattened()) {
			if (cls.isBottomEntity() || cls.isTopEntity()) {
				continue;
			}
			String oboId = graph.getIdentifier(cls);
			if (oboId != null) {
				classSubSet.add(oboId);
			}
		}
	}
	finally {
		reasoner.dispose();
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:GoIEPRestrictionsRule.java

示例15: GoIPICatalyticActivityRestrictionsRule

import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入方法依赖的package包/类
public GoIPICatalyticActivityRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) {
	this.message = MESSAGE;
	this.violationType = ViolationType.Warning;
	
	evidences = eco.getAllValidEvidenceIds("IPI", true);
	
	classSubSet = new HashSet<String>();
	
	OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0003824"); // catalytic activity
	OWLReasonerFactory factory = new ElkReasonerFactory();
	OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology());
	try {
		NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false);
		for(OWLClass cls : nodeSet.getFlattened()) {
			if (cls.isBottomEntity() || cls.isTopEntity()) {
				continue;
			}
			String oboId = graph.getIdentifier(cls);
			if (oboId != null) {
				classSubSet.add(oboId);
			}
		}
	}
	finally {
		reasoner.dispose();
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:GoIPICatalyticActivityRestrictionsRule.java


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