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


Java OWLOntology.getEquivalentClassesAxioms方法代码示例

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


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

示例1: buildSimpleDefMap

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private void buildSimpleDefMap() {
	simpleDefMap = new HashMap<OWLClass,Set<OWLClassExpression>>();
	OWLOntology o = getGraph().getSourceOntology();
	for (OWLClass c : o.getClassesInSignature()) {
		for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(c)) {
			Set<OWLClassExpression> elts = new HashSet<OWLClassExpression>();
			for (OWLClassExpression x : eca.getClassExpressions()) {
				// assume one logical definitionper class - otherwise choose arbitrary
				if (x instanceof OWLObjectIntersectionOf) {
					if (getReachableOWLClasses(x, elts) && elts.size() > 0) {
						//LOG.info(c+" def= "+elts);
						simpleDefMap.put(c, elts);						
					}
				}
			}
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:19,代码来源:CompositionalClassPredictor.java

示例2: UnfoldingVisitor

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
UnfoldingVisitor(Set<OWLClass> unfoldClasses, OWLOntology ontology) throws NonDeterministicUnfoldException {
	this.unfoldClasses = new HashMap<OWLClass, OWLClassExpression>();
	factory = ontology.getOWLOntologyManager().getOWLDataFactory();
	
	for(OWLClass owlClass : unfoldClasses) {
		Set<OWLEquivalentClassesAxiom> eqAxioms = ontology.getEquivalentClassesAxioms(owlClass);
		if (eqAxioms != null && !eqAxioms.isEmpty()) {
			if(eqAxioms.size() > 1) {
				throw new NonDeterministicUnfoldException("Non deterministic unfold for class: "+owlClass.getIRI());
			}
			OWLEquivalentClassesAxiom eqAxiom = eqAxioms.iterator().next();
			Set<OWLClassExpression> expressions = eqAxiom.getClassExpressionsMinus(owlClass);
			if (expressions.size() == 1) {
				this.unfoldClasses.put(owlClass, expressions.iterator().next());
			}
			else if (expressions.size() > 1) {
				OWLClassExpression ce = factory.getOWLObjectIntersectionOf(expressions);
				this.unfoldClasses.put(owlClass, ce);
			}
		}
	}
	
	// TODO check that there are no cycles in the unfold expressions, otherwise this unfold will not terminate!
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:TBoxUnFoldingTool.java

示例3: reverseOWLObjectUnionOfs

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Reverse all {@code OWLObjectUnionOf}s, that are operands in 
 * an {@code OWLEquivalentClassesAxiom}, into individual {@code OWLSubClassOfAxiom}s, where 
 * the classes part of the {@code OWLObjectUnionOf} become subclasses, and 
 * the original first operand of the {@code OWLEquivalentClassesAxiom} superclass. 
 * <p>
 * Note that such {@code OWLEquivalentClassesAxiom}s are not removed from the ontology, 
 * only {@code OWLSubClassOfAxiom}s are added. The axioms containing 
 * {@code OWLObjectUnionOf}s will be removed by calling {@link #removeOWLObjectUnionOfs()}, 
 * in order to give a chance to {@link #convertEquivalentClassesToSuperClasses()} 
 * to do its job before.
 * 
 * @see #performDefaultModifications()
 * @see #removeOWLObjectUnionOfs()
 * @see #convertEquivalentClassesToSuperClasses()
 */
private void reverseOWLObjectUnionOfs() {
    log.info("Reversing OWLObjectUnionOfs into OWLSubClassOfAxioms");
    for (OWLOntology ont : this.getOwlGraphWrapper().getAllOntologies()) {
        for (OWLClass cls : ont.getClassesInSignature()) {
            for (OWLEquivalentClassesAxiom eca : ont.getEquivalentClassesAxioms(cls)) {
                for (OWLClassExpression ce : eca.getClassExpressions()) {
                    if (ce instanceof OWLObjectUnionOf) {
                        for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) {
                            //we reverse only named classes
                            if (child instanceof OWLClass) {
                                this.getOwlGraphWrapper().getManager().addAxiom(ont, 
                                        ont.getOWLOntologyManager().getOWLDataFactory().
                                            getOWLSubClassOfAxiom((OWLClass) child, cls));
                            }
                        }
                    }
                }
            }
        }
    }
    this.triggerWrapperUpdate();
    log.info("OWLObjectUnionOf reversion done.");
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:40,代码来源:OWLGraphManipulator.java

示例4: cacheReverseUnionMap

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private void cacheReverseUnionMap() {
	synchronized (edgeCacheMutex) {
	    extraSubClassOfEdges = new HashMap<OWLObject, Set<OWLGraphEdge>>();
           if (!config.isGraphReasonedAndRelaxed) {
	        for (OWLOntology o : getAllOntologies()) {
	            for (OWLClass cls : o.getClassesInSignature()) {
	                for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(cls)) {
	                    for (OWLClassExpression ce : eca.getClassExpressions()) {
	                        if (ce instanceof OWLObjectUnionOf) {
	                            for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) {
	                                if (!extraSubClassOfEdges.containsKey(child)) {
	                                    extraSubClassOfEdges.put(child, new OWLGraphEdgeSet());
	                                }
	                                extraSubClassOfEdges.get(child).add(
	                                        createSubClassOfEdge(child,cls,o,eca));
	                            }
	                        }
	                    }
	                }
	            }
	        }
	    }
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:OWLGraphWrapperEdges.java

示例5: loadDefinition

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private OWLClassExpression loadDefinition(OWLClass cls) {
	Set<OWLClassExpression> possibleDefinitions = new HashSet<>();
	for (OWLOntology ontology : ontologies) {
		for (OWLEquivalentClassesAxiom definingAxiom : ontology.getEquivalentClassesAxioms(cls)) {
			possibleDefinitions.addAll(definingAxiom.getClassExpressionsMinus(cls));
		}
	}
	if (possibleDefinitions.size() < 1) {
		return null;
	}
	if (possibleDefinitions.size() > 1) {
		throw new RuntimeException("Multiple candidate definitions found for class: " + cls);
	}
	return possibleDefinitions.iterator().next();
}
 
开发者ID:julianmendez,项目名称:uel,代码行数:16,代码来源:UelOntology.java

示例6: getEquivalentClasses

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
public static Set<OWLClassExpression> getEquivalentClasses(OWLClass cls, OWLOntology ont) {
	Set<OWLClassExpression> expressions;
	if (cls != null && ont != null) {
		Set<OWLEquivalentClassesAxiom> axioms = ont.getEquivalentClassesAxioms(cls);
		expressions = new HashSet<>(axioms.size());
		for(OWLEquivalentClassesAxiom ax : axioms) {
			expressions.addAll(ax.getClassExpressions());
		}
		expressions.remove(cls); // set should not contain the query cls
	}
	else {
		expressions = Collections.emptySet();
	}
	return expressions;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:16,代码来源:OwlHelper.java

示例7: check

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
@Override
public Collection<CheckWarning> check(OWLGraphWrapper graph, Collection<OWLObject> allOwlObjects) {
	OWLOntology ontology = graph.getSourceOntology();
	List<CheckWarning> violations = new ArrayList<CheckWarning>();
	for(OWLClass cls : ontology.getClassesInSignature()) {
		Set<OWLEquivalentClassesAxiom> equivalentClassesAxioms = ontology.getEquivalentClassesAxioms(cls);
		if (equivalentClassesAxioms != null && !equivalentClassesAxioms.isEmpty()) {
			for (OWLEquivalentClassesAxiom owlEquivalentClassesAxiom : equivalentClassesAxioms) {
				for (OWLClassExpression ex : owlEquivalentClassesAxiom.getClassExpressions()) {
					if (ex instanceof OWLClass)
						continue;
					Set<OWLClass> classesInSignature = ex.getClassesInSignature();
					if (classesInSignature != null && classesInSignature.contains(cls)) {
						String id = graph.getIdentifier(cls);
						String message = "Class "+id+" has a self reference in its logical definition: "+owlEquivalentClassesAxiom;
						CheckWarning warning = new CheckWarning("Self_Reference_In_Definition", message , isFatal(), cls.getIRI());
						violations.add(warning);
					}
				}
			}
		}
	}
	if (!violations.isEmpty()) {
		return violations;
	}
	return null;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:SelfReferenceInDefinition.java

示例8: hasMatchingIntersection

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Search for the first class with a matching equivalent class definition. 
 * 
 * @param c
 * @param genus
 * @param relation
 * @return match or null
 */
private OWLClass hasMatchingIntersection(OWLClass c, OWLClass genus, OWLObjectProperty relation) {
	for(OWLOntology o : allOntologies) {
		Set<OWLEquivalentClassesAxiom> eqAxioms = o.getEquivalentClassesAxioms(c);
		for (OWLEquivalentClassesAxiom eqAxiom : eqAxioms) {
			Set<OWLClassExpression> expressions = eqAxiom.getClassExpressionsMinus(c);
			for (OWLClassExpression expression : expressions) {
				if (expression instanceof OWLObjectIntersectionOf) {
					OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) expression;
					OWLClass differentiaCls = null;
					boolean matchesGenus = false;
					boolean matchesRelation = false;
					Set<OWLClassExpression> operands = intersection.getOperands();
					if (operands.size() == 2) {
						for (OWLClassExpression operand : operands) {
							if (operand.isAnonymous() == false) {
								OWLClass currentGenus = operand.asOWLClass();
								if (genus.equals(currentGenus)) {
									matchesGenus = true;
								}
							}
							else if (operand instanceof OWLObjectSomeValuesFrom) {
								OWLObjectSomeValuesFrom differentia = (OWLObjectSomeValuesFrom) operand;
								if (relation.equals(differentia.getProperty())) {
									matchesRelation = true;
									OWLClassExpression filler = differentia.getFiller();
									if (!filler.isAnonymous() && !filler.isOWLNothing() && !filler.isOWLThing()) {
										differentiaCls = filler.asOWLClass();
									}
								}
							}
						}
						if (matchesGenus && matchesRelation ) {
							 return differentiaCls;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:50,代码来源:LinkMaker.java


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