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


Java OWLEquivalentClassesAxiom类代码示例

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


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

示例1: next

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
@Override
public Set<OWLEquivalentClassesAxiom> next() {
	compute();
	if (!hasNext) {
		throw new NoSuchElementException();
	}

	isComputed = false;

	Set<OWLAxiom> axioms = uelModel.renderUnifier(unifier);
	return axioms.stream().map(axiom -> {
		if (axiom instanceof OWLEquivalentClassesAxiom)
			return (OWLEquivalentClassesAxiom) axiom;
		throw new IllegalStateException("Expected OWLEquivalentClassesAxiom");
	}).collect(Collectors.toSet());
}
 
开发者ID:julianmendez,项目名称:uel,代码行数:17,代码来源:UnifierIterator.java

示例2: hasFilterClass

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
/**
 * Check that there is an axiom, which use a class (in its signature) that
 * has a ancestor in the root term set.
 * 
 * @param axioms set to check
 * @param rootTerms set root of terms
 * @return boolean
 */
private boolean hasFilterClass(Set<OWLClassAxiom> axioms, Set<OWLClass> rootTerms) {
    if (axioms != null && !axioms.isEmpty()) {
        for (OWLClassAxiom ax : axioms) {
            if (ax instanceof OWLEquivalentClassesAxiom) {
                Set<OWLClass> signature = ax.getClassesInSignature();
                for (OWLClass sigCls : signature) {
                    NodeSet<OWLClass> superClasses = reasoner.getSuperClasses(sigCls, false);
                    for(OWLClass root : rootTerms) {
                        if (superClasses.containsEntity(root)) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:CommandRunner.java

示例3: buildSimpleDefMap

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

示例4: expressionToClass

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
private OWLClass expressionToClass(OWLClassExpression x) {
	if (x instanceof OWLClass)
		return (OWLClass)x;
	if (this.expressionToClassMap.containsKey(x))
		return this.expressionToClassMap.get(x);
	OWLClass c = owlDataFactory.getOWLClass(IRI.create("http://owlsim.org#"+idNum));
	idNum++;

	OWLEquivalentClassesAxiom eca =
		owlDataFactory.getOWLEquivalentClassesAxiom(c, x);
	owlOntologyManager.addAxiom(sourceOntology, eca);
	expressionToClassMap.put(x, c);

	// fully fold tbox (AND and SOME only)
	if (x instanceof OWLObjectIntersectionOf) {
		for (OWLClassExpression y : ((OWLObjectIntersectionOf)x).getOperands()) {
			expressionToClass(y);
		}
	}
	else if (x instanceof OWLObjectSomeValuesFrom) {
		expressionToClass(((OWLObjectSomeValuesFrom)x).getFiller());
	}
	return c;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:OldSimpleOwlSim.java

示例5: materializeClassExpressionsReferencedBy

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
public Set<OWLClass> materializeClassExpressionsReferencedBy(OWLObjectProperty p) {
	Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>();
	for (OWLAxiom ax : outputOntology.getReferencingAxioms(p, Imports.INCLUDED)) {
		if (ax instanceof OWLSubClassOfAxiom) {
			xs.addAll(getClassExpressionReferencedBy(p, ((OWLSubClassOfAxiom)ax).getSuperClass()));
		}
		else if (ax instanceof OWLClassAssertionAxiom) {
			xs.addAll(getClassExpressionReferencedBy(p, ((OWLClassAssertionAxiom)ax).getClassExpression()));
		}
		else if (ax instanceof OWLEquivalentClassesAxiom) {
			for (OWLClassExpression x : ((OWLEquivalentClassesAxiom)ax).getClassExpressions()) {
				xs.addAll(getClassExpressionReferencedBy(p,x));
			}
		}
	}
	return materializeClassExpressions(xs);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:18,代码来源:AbstractSimPreProcessor.java

示例6: UnfoldingVisitor

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

示例7: unfoldAxiom

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
OWLEquivalentClassesAxiom unfoldAxiom(OWLEquivalentClassesAxiom ax, OWLClass owlClass) {
	Set<OWLClassExpression> existing = ax.getClassExpressionsMinus(owlClass);
	OWLClassExpression ce;
	if (existing == null || existing.isEmpty()) {
		return null;
	}
	else if (existing.size() == 1) {
		ce = existing.iterator().next();
	}
	else {
		ce = factory.getOWLObjectIntersectionOf(existing);
	}
	if(LOG.isDebugEnabled()) {
		LOG.debug("Unfolding axiom: "+ax);
	}
	OWLClassExpression unfolded = ce.accept(this);
	
	if (unfolded != null) {
		return factory.getOWLEquivalentClassesAxiom(owlClass, unfolded);
	}
	return null;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:23,代码来源:TBoxUnFoldingTool.java

示例8: reverseOWLObjectUnionOfs

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

示例9: visit

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
@Override
public void visit(OWLEquivalentClassesAxiom axiom) {
	Set<OWLClassExpression> newExpressions = new HashSet<OWLClassExpression>();
	boolean changed = false;
	for (OWLClassExpression ce : axiom.getClassExpressions()) {
		HandlerResult result = ce.accept(handler);
		if (result != null) {
			if (result.remove) {
				// skip handling and immediately remove and return
				remove(ontology, axiom);
				return;
			}
			changed = true;
			newExpressions.add(result.modified);
		}
		else {
			newExpressions.add(ce);
		}
	}
	if (changed) {
		remove(ontology, axiom);
		OWLEquivalentClassesAxiom newAxiom = factory.getOWLEquivalentClassesAxiom(newExpressions, axiom.getAnnotations());
		add(ontology, newAxiom);
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:CardinalityContraintsTools.java

示例10: cacheReverseUnionMap

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

示例11: filterEquivalentNamedClassPairs

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
/**
 * Given a list of equivalent classes axiom, remove all axioms which use a
 * class from the ignore set. Maps the class to it's identifier via the
 * given graph.
 * 
 * @param all
 * @param ignores
 * @param graph
 * @return filtered list
 */
private List<OWLEquivalentClassesAxiom> filterEquivalentNamedClassPairs(
		List<OWLEquivalentClassesAxiom> all, Set<String> ignores, OWLGraphWrapper graph)
{
	List<OWLEquivalentClassesAxiom> filtered = new ArrayList<OWLEquivalentClassesAxiom>(all.size());
	for (OWLEquivalentClassesAxiom axiom : all) {
		Set<OWLClass> namedClasses = axiom.getNamedClasses();
		boolean add = true;
		for (OWLClass owlClass : namedClasses) {
			String id = graph.getIdentifier(owlClass);
			if (ignores.contains(id)) {
				add = false;
				break;
			}
		}
		if (add) {
			filtered.add(axiom);
		}
	}
	return filtered;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:31,代码来源:OboOntologyReleaseRunner.java

示例12: handleIntersection

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
private void handleIntersection(List<CheckWarning> warnings, Set<OWLOntology> allOntologies,
		OWLEquivalentClassesAxiom axiom, OWLObjectIntersectionOf intersection, OWLPrettyPrinter pp) 
{
	for(OWLClassExpression operand : intersection.getOperandsAsList()) {
		OWLClass operandCls = null;
		if (!operand.isAnonymous()) {
			operandCls = operand.asOWLClass();
		}
		else if (operand instanceof OWLObjectSomeValuesFrom) {
			OWLObjectSomeValuesFrom ristriction = (OWLObjectSomeValuesFrom) operand;
			OWLClassExpression filler = ristriction.getFiller();
			if (!filler.isAnonymous()) {
				operandCls = filler.asOWLClass();
			}
		}
		else {
			// not translatable to OBO
			handleGeneric(warnings, allOntologies, axiom, operand, pp);
		}
		if (operandCls != null && isDangling(operandCls, allOntologies)) {
			final IRI iri = operandCls.getIRI();
			String message = "Dangling reference "+iri+" in INTERSECTION_OF axiom: "+pp.render(axiom);
			warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_INTERSECTION_OF.getTag()));
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:DanglingReferenceCheck.java

示例13: handleUnionOf

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
private void handleUnionOf(List<CheckWarning> warnings, Set<OWLOntology> allOntologies, 
		OWLEquivalentClassesAxiom axiom, OWLObjectUnionOf union, OWLPrettyPrinter pp) 
{
	List<OWLClassExpression> operands = union.getOperandsAsList();
	for(OWLClassExpression operand : operands) {
		if (!operand.isAnonymous()) {
			OWLClass operandCls = operand.asOWLClass();
			if (isDangling(operandCls, allOntologies)) {
				final IRI iri = operandCls.getIRI();
				String message = "Dangling reference "+iri+" in UNION_OF axiom: "+pp.render(axiom);
				warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_UNION_OF.getTag()));
			}
		}
		else {
			// not translatable to OBO
			handleGeneric(warnings, allOntologies, axiom, operand, pp);
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:DanglingReferenceCheck.java

示例14: checkNewOrRetiredDescription

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
/**
 * Check whether a given change is a new or retired description
 * @param effAdds	true if checking additions, false if checking removals
 * @param man	OWL ontology manager
 * @param ax	OWL axiom to be checked
 * @param newTerms	Set of new terms used in this axiom
 * @param eval	Syntactic locality evaluator
 * @return New or Retired Description-type change, or null if not one
 * @throws OWLOntologyCreationException	Ontology creation exception
 */
private CategorisedChange checkNewOrRetiredDescription(boolean effAdds, OWLOntologyManager man, OWLAxiom ax, 
		Set<OWLEntity> newTerms, SyntacticLocalityEvaluator eval) throws OWLOntologyCreationException {
	CategorisedChange change = null;
	if(!newTerms.isEmpty()) {
		boolean atomicLhs = true;
		if(ax instanceof OWLSubClassOfAxiom) {
			OWLClassExpression c = ((OWLSubClassOfAxiom)ax).getSubClass();
			if(c.isAnonymous() || !newTerms.contains(c))
				atomicLhs = false;
		}
		else if(ax instanceof OWLEquivalentClassesAxiom)
			atomicLhs = false;

		if(atomicLhs && !(eval.isLocal(ax, newTerms))) {
			if(effAdds) 
				change = new CategorisedEffectualAddition(ax, EffectualAdditionCategory.NEWDESCRIPTION, new HashSet<OWLAxiom>(), newTerms);
			else 
				change = new CategorisedEffectualRemoval(ax, EffectualRemovalCategory.RETIREDDESCRIPTION, new HashSet<OWLAxiom>(), newTerms);
		}
	}
	return change;
}
 
开发者ID:rsgoncalves,项目名称:ecco,代码行数:33,代码来源:CategoricalDiff.java

示例15: transformOWLEquivalentClassesAxiom

import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; //导入依赖的package包/类
private List<Axiom> transformOWLEquivalentClassesAxiom(
        OWLEquivalentClassesAxiom a) {
    List<Axiom> axioms = new ArrayList<Axiom>();
    List<OWLClassExpression> exps = a.getClassExpressionsAsList();

    int size = exps.size();

    for (int i = 0; i < size - 1; i++) {
        try {
            OWLClassExpression e1 = exps.get(i);
            Concept concept1 = getConcept(e1);
            for (int j = i; j < size; j++) {
                OWLClassExpression e2 = exps.get(j);
                if (e1 == e2)
                    continue;
                Concept concept2 = getConcept(e2);
                axioms.add(new ConceptInclusion(concept1, concept2));
                axioms.add(new ConceptInclusion(concept2, concept1));
            }
        } catch(UnsupportedOperationException e) {
            problems.add(e.getMessage());
        }
    }
    return axioms;
}
 
开发者ID:aehrc,项目名称:ontology-core,代码行数:26,代码来源:OWLImporter.java


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