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


Java OWLReasoner类代码示例

本文整理汇总了Java中org.semanticweb.owlapi.reasoner.OWLReasoner的典型用法代码示例。如果您正苦于以下问题:Java OWLReasoner类的具体用法?Java OWLReasoner怎么用?Java OWLReasoner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: highlightPropertyIfUnsatisfiable

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
private void highlightPropertyIfUnsatisfiable(final OWLEntity entity, final StyledDocument doc, final int tokenStartIndex, final int tokenLength) {
	try {
		getOWLModelManager().getReasonerPreferences().executeTask(OptionalInferenceTask.SHOW_OBJECT_PROPERTY_UNSATISFIABILITY,
                () -> {
                    OWLObjectProperty prop = (OWLObjectProperty) entity;
                    OWLReasoner reasoner = getOWLModelManager().getReasoner();
                    boolean consistent = reasoner.isConsistent();
                    if(!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
                        doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
                    }
                });
	}
	catch (Exception e) {
		logger.warn("An error occurred whilst highlighting an unsatisfiable property: {}", e);
	}
}
 
开发者ID:lukasged,项目名称:oops-plugin,代码行数:17,代码来源:OOPSTreeCellRenderer.java

示例2: getIndividuals

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * @param superclass
 * @param o
 * @return
 */
private static Set<OWLIndividual> getIndividuals(String superclass,
		OWLOntology o) {
	
	OWLReasoner reasoner = PelletReasonerFactory.getInstance()
			.createReasoner(o);
	Set<OWLNamedIndividual> instances = reasoner.getInstances(
			OWL.Class(IRI.create(superclass)), false).getFlattened();
	
	// filter out all owl:sameAs instances...
	Set<OWLIndividual> ind = new TreeSet<>();
	for (OWLNamedIndividual i : instances) {
		ind.add(i);
	}
	logger.info("|I| = " + ind.size());
	logger.debug("I = " + ind);

	return ind;

}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:25,代码来源:R2VManager.java

示例3: highlightPropertyIfUnsatisfiable

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
private void highlightPropertyIfUnsatisfiable(final OWLEntity entity, final StyledDocument doc,
		final int tokenStartIndex, final int tokenLength) {
	try {
		getOWLModelManager().getReasonerPreferences()
				.executeTask(OptionalInferenceTask.SHOW_OBJECT_PROPERTY_UNSATISFIABILITY, () -> {
					OWLObjectProperty prop = (OWLObjectProperty) entity;
					OWLReasoner reasoner = getOWLModelManager().getReasoner();
					boolean consistent = reasoner.isConsistent();
					if (!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
						doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
					}
				});
	} catch (Exception e) {
		logger.warn("An error occurred whilst highlighting an unsatisfiable property: {}", e);
	}
}
 
开发者ID:md-k-sarker,项目名称:OWLAx,代码行数:17,代码来源:OWLCellRenderer.java

示例4: QueryEngineImpl

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * QueryEngineImpl constructor
 *
 * @param manager    An OWLOntologyManager instance of OWLAPI v3
 * @param reasoner   An OWLReasoner instance.
 * @param strictMode If strict mode is enabled the query engine will throw a QueryEngineException if data types withing the query are not correct (e.g. Class(URI_OF_AN_INDIVIDUAL))
 */
public QueryEngineImpl(OWLOntologyManager manager, OWLReasoner reasoner, boolean strictMode) {
    this.manager = manager;
    this.reasoner = reasoner;
    this.factory = manager.getOWLDataFactory();
    this.strictMode = strictMode;
    reasoner.getRootOntology()
            .getAxioms(AxiomType.ANNOTATION_ASSERTION, Imports.INCLUDED)
            .stream()
            .filter(ax -> ax.getSubject() instanceof IRI)
            .forEach(ax -> {
                unannotatedAxioms.add(ax.getAxiomWithoutAnnotations());
                annotationAssertionsBySubject.put((IRI) ax.getSubject(), ax);
            });
    Set<OWLClass> classesInSignature = reasoner.getRootOntology().getClassesInSignature(Imports.INCLUDED);
    classesInSignature.add(factory.getOWLThing());
    classesInSignature.add(factory.getOWLNothing());
    classes = ImmutableSet.copyOf(classesInSignature);
    classIris = ImmutableSet.copyOf(classes.stream().map(OWLClass::getIRI).collect(toSet()));

    annotationPropertyIris = ImmutableSet.copyOf(reasoner.getRootOntology().getAnnotationPropertiesInSignature(Imports.INCLUDED).stream().map(
            OWLNamedObject::getIRI).collect(toSet()));
}
 
开发者ID:protegeproject,项目名称:sparql-dl-api,代码行数:30,代码来源:QueryEngineImpl.java

示例5: AbstractLegoTranslator

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
protected AbstractLegoTranslator(OWLOntology model, CurieHandler curieHandler, SimpleEcoMapper mapper) {
    super(model.getOWLOntologyManager().getOWLDataFactory());
    this.curieHandler = curieHandler;
    goCodes = new FindGoCodes(mapper, curieHandler);

    mf = OBOUpperVocabulary.GO_molecular_function.getOWLClass(f);
    cc = f.getOWLClass(IRI.create("http://purl.obolibrary.org/obo/GO_0005575"));
    bp = OBOUpperVocabulary.GO_biological_process.getOWLClass(f);

    bpSet = new HashSet<>();
    mfSet = new HashSet<>();
    ccSet = new HashSet<>();

    ElkReasonerFactory rf = new ElkReasonerFactory();
    OWLReasoner reasoner = rf.createReasoner(model);
    fillAspects(model, reasoner, curieHandler, bpSet, mfSet, ccSet, bp, mf, cc);
    reasoner.dispose();

    assignedByDefault = "GO_Noctua";
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:21,代码来源:AbstractLegoTranslator.java

示例6: getAllSubClasses

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
protected static Set<OWLClass> getAllSubClasses(OWLClass cls, OWLReasoner r, boolean reflexive, String idSpace, CurieHandler curieHandler) {
    Set<OWLClass> allSubClasses = r.getSubClasses(cls, false).getFlattened();
    Iterator<OWLClass> it = allSubClasses.iterator();
    while (it.hasNext()) {
        OWLClass current = it.next();
        if (current.isBuiltIn()) {
            it.remove();
            continue;
        }
        String id = curieHandler.getCuri(current);
        if (id.startsWith(idSpace) == false) {
            it.remove();
            continue;
        }
    }
    if (reflexive) {
        allSubClasses.add(cls);
    }
    return allSubClasses;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:21,代码来源:AbstractLegoTranslator.java

示例7: create

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
public static InferenceProvider create(OWLReasoner r, OWLOntology ont) {
	Map<OWLNamedIndividual, Set<OWLClass>> inferredTypes = new HashMap<>();
	boolean isConsistent = r.isConsistent();
	if (isConsistent) {
		Set<OWLNamedIndividual> individuals = ont.getIndividualsInSignature();
		for (OWLNamedIndividual individual : individuals) {
			Set<OWLClass> inferred = new HashSet<>();
			Set<OWLClass> flattened = r.getTypes(individual, true).getFlattened();
			for (OWLClass cls : flattened) {
				if (cls.isBuiltIn() == false) {
					inferred.add(cls);
				}
			}
			inferredTypes.put(individual, inferred);
		}
	}
	return new MapInferenceProvider(isConsistent, inferredTypes);
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:MapInferenceProvider.java

示例8: isEdgeEntailed

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
public boolean isEdgeEntailed(OWLEdge e, OWLOntology currentOntology, OWLReasoner reasoner) {
	OWLOntologyManager m = getManager();

	Set<OWLSubClassOfAxiom> scas = currentOntology.getSubClassAxiomsForSubClass(e.c);
	Set<OWLSubClassOfAxiom> rmAxioms = new HashSet<OWLSubClassOfAxiom>();
	for (OWLSubClassOfAxiom sca : scas) {
		if (sca.getSuperClass().equals(e.p)) {
			LOG.info("REMOVING: "+sca);
			rmAxioms.add(sca);
		}
	}
	boolean isEdgeAsserted = rmAxioms.size() > 0;
	if (isEdgeAsserted) {
		m.removeAxioms(currentOntology, rmAxioms);
		reasoner.flush();
	}
	boolean isEntailed;
	isEntailed = reasoner.getSuperClasses(e.c, false).containsEntity(e.p);
	if (isEdgeAsserted) {
		m.addAxioms(currentOntology, rmAxioms);
		reasoner.flush();
	}

	return isEntailed;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:ProvenanceReasonerWrapper.java

示例9: printHierarchy

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * Print the class hierarchy from this class down, assuming this class is at
 * the given level. Makes no attempt to deal sensibly with multiple
 * inheritance.
 */
private void printHierarchy(OWLReasoner reasoner,
                            OWLClass clazz, int level) throws OWLException {
    /*
     * Only print satisfiable classes -- otherwise we end up with bottom
     * everywhere
     */
    if (reasoner.isSatisfiable(clazz)) {
        for (int i = 0; i < level * INDENT; i++) {
            out.print(" ");
        }
        out.println(labelFor(clazz));
        /* Find the children and recurse */
        for (OWLClass child : reasoner.getSubClasses(clazz, true)
                .getFlattened()) {
            if (!child.equals(clazz)) {
                printHierarchy(reasoner, child, level + 1);
            }
        }
    }
}
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:26,代码来源:OwlReader2.java

示例10: getExplicitOWLDisjointnessAxioms

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * OWLDisjointAxiom(A,B,C)
 * @param reasoner
 * @param ontology
 * @param cls
 * @return
 */
public static OWLClassNodeSet getExplicitOWLDisjointnessAxioms(OWLReasoner reasoner, OWLOntology ontology, OWLClass cls){
	
	OWLClassNodeSet nodeSet = new OWLClassNodeSet();
	
	for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(cls)) {                	
           for (OWLClassExpression op : ax.getClassExpressions()) {
               if (!op.isAnonymous() && !op.equals(cls)) { //Op must be differnt to ce
                   nodeSet.addNode(reasoner.getEquivalentClasses(op));
               }
           }
       }
	
	return nodeSet;
	
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:23,代码来源:DisjointnessAxiomExtractor.java

示例11: getExplicitDLDisjointnessAxioms

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * A ^ B -> bottom
 * @param reasoner
 * @param ontology
 * @param cls
 * @author Shuo Zhang
 * @return
 */
public static OWLClassNodeSet getExplicitDLDisjointnessAxioms(OWLReasoner reasoner, OWLOntology ontology, OWLClass cls){
	
	OWLClassNodeSet nodeSet = new OWLClassNodeSet();
	
	OWLClassExpression subExp;
   	Set<OWLClassExpression> set;
       for (OWLSubClassOfAxiom sax : ontology.getSubClassAxiomsForSuperClass(OWLManager.getOWLDataFactory().getOWLNothing())) {
       	subExp = sax.getSubClass();
       	if (subExp instanceof OWLObjectIntersectionOf) {
       		set = subExp.asConjunctSet();
       		if (set.contains(cls) && set.size() == 2) {
       			for (OWLClassExpression op : set) {
       				if (!op.equals(cls) && !op.isAnonymous()) {
       					nodeSet.addNode(reasoner.getEquivalentClasses(op));
       					break;
       				}
       			}
       		}
       	}
       } 
	
       return nodeSet;
       
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:33,代码来源:DisjointnessAxiomExtractor.java

示例12: removeRedundantSubClassAxioms

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
/**
 * Remove the redundant and marked as inferred super class assertions for
 * each class in the ontology signature. Uses the reasoner to infer the
 * direct super classes.
 * 
 * @param ontology
 * @param reasoner
 * @return map of class to set of redundant axioms
 */
public static Map<OWLClass, Set<RedundantAxiom>> removeRedundantSubClassAxioms(OWLOntology ontology, OWLReasoner reasoner) {
	Iterable<OWLClass> classes = ontology.getClassesInSignature();
	Map<OWLClass, Set<RedundantAxiom>> axioms = findRedundantSubClassAxioms(classes, ontology, reasoner);
	if (!axioms.isEmpty()) {
		Set<OWLSubClassOfAxiom> allAxioms = new THashSet<OWLSubClassOfAxiom>();
		for(OWLClass cls : axioms.keySet()) {
			for(RedundantAxiom redundantAxiom : axioms.get(cls)) {
				allAxioms.add(redundantAxiom.getAxiom());
			}
		}
		OWLOntologyManager manager = ontology.getOWLOntologyManager();
		manager.removeAxioms(ontology, allAxioms);
		LOG.info("Removed "+axioms.size()+" redundant axioms.");
	}
	return axioms;
	
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:RedundantInferences.java

示例13: changeReasoner

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
void changeReasoner() {
	ElkReasoner newReasoner = null;
	OWLReasoner reasoner = getEditorKit().getOWLModelManager()
			.getOWLReasonerManager().getCurrentReasoner();
	if (reasoner instanceof ElkReasoner) {
		newReasoner = (ElkReasoner) reasoner;
	}
	if (newReasoner == reasoner_) {
		return;
	}
	// else
	if (reasoner_ != null && reasoner_.equals(newReasoner)) {
		return;
	}
	// else
	reasoner_ = newReasoner;
	for (ChangeListener listener : listeners_) {
		listener.reasonerChanged();
	}
}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:21,代码来源:ElkProofService.java

示例14: findDescendants

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的package包/类
protected Set<OWLClass> findDescendants(OWLReasoner r, String expr, Integer numExpected) throws TimeOutException, FreshEntitiesException, InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, OWLParserException {
	System.out.println("Query: "+expr);
	OWLClassExpression qc = parseOMN(expr);
	Set<OWLClass> clzs = r.getSubClasses(qc, false).getFlattened();
	clzs.remove(r.getRootOntology().getOWLOntologyManager().getOWLDataFactory().getOWLNothing());
	if (!qc.isAnonymous())
		clzs.add((OWLClass) qc);
	System.out.println("NumD:"+clzs.size());
	for (OWLClass c : clzs) {
		System.out.println("  D:"+c);
	}
	if (numExpected != null) {
		assertEquals(numExpected.intValue(), clzs.size());
	}
	return clzs;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:AbstractReasonerTest.java

示例15: main

import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入依赖的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


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