本文整理匯總了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);
}
}
}
}
}
}
示例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!
}
示例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.");
}
示例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));
}
}
}
}
}
}
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}