org.semanticweb.owlapi.model.ClassExpressionType Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.ClassExpressionType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChEBIParser.java From act with GNU General Public License v3.0 | 6 votes |
private Set<OWLClass> get_has_role_parents(OWLClass clazz) { Set<OWLClass> roles = new HashSet<OWLClass>(); for (OWLClassExpression sup: clazz.getSuperClasses(ontology)) { ClassExpressionType typ = sup.getClassExpressionType(); switch (typ) { case OBJECT_SOME_VALUES_FROM: Set<OWLObjectProperty> properties = sup.getObjectPropertiesInSignature(); Set<OWLClass> classes = sup.getClassesInSignature(); if (singletonPropertyHasRole(properties) && classes.size() == 1) { OWLClass has_role_parent = classes.toArray(new OWLClass[0])[0]; roles.add(has_role_parent); // err.println("\t\t Added parent: " + has_role_parent); } // else { // err.println("Was expecting singleton sets for properties and classes."); // err.println("Got more/less: " + properties + " " + classes); // System.exit(-1); // } break; default: // err.println("\t Default (SubClassOf): " + sup); break; } } return roles; }
Example #2
Source File: EliminateEJVar.java From quetzal with Eclipse Public License 2.0 | 6 votes |
/** * return named properties p such that c \subseteq \some inv(p) T * @param c * @return */ protected Set<URI> getNamedInverseSuperPropertiesOrSelf(OWLClassExpression c) { Set<OWLClassExpression> subs = taxo.getAllSubsumers(c); Set<URI> ret = new HashSet<URI>(); for (OWLClassExpression ex: subs) { if (ex.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM)) { OWLObjectSomeValuesFrom rest = (OWLObjectSomeValuesFrom) ex; OWLObjectPropertyExpression prop = rest.getProperty().getSimplified(); if (prop.isAnonymous()) { OWLObjectProperty namedProp = prop.getNamedProperty(); ret.add(namedProp.getIRI().toURI()); } } } return ret; }
Example #3
Source File: TaxonomyImpl.java From quetzal with Eclipse Public License 2.0 | 6 votes |
protected void retainOnlyExistentialRestrictions(Set<OWLClassExpression> cs) { //Set<OWLClassExpression> add = new HashSet<OWLClassExpression>(); for (Iterator<OWLClassExpression> it = cs.iterator(); it.hasNext();) { OWLClassExpression c = it.next(); if (!c.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM) && !c.getClassExpressionType().equals(ClassExpressionType.DATA_SOME_VALUES_FROM)) { it.remove(); /*c = aterm2complexAtermEq.get(c); if (c!=null && ATermUtils.isSomeValues(c)) { add.add(c); }*/ } } //cs.addAll(add); }
Example #4
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public Set<OWLClass> getUnsatisfiableNamedClasses() { if (unsatisfiableClasses == null) { unsatisfiableClasses = new HashSet<OWLClass>(); // unsatisfiabe named classes C are in the negative closure in the form // subclass( C, not(C)) for (OWLSubClassOfAxiom ax: getNegativeInclInNegClosure()) { OWLClassExpression sub = ax.getSubClass(); OWLClassExpression sup = ax.getSuperClass(); if (!sub.isAnonymous() && sup.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) && ((OWLObjectComplementOf) sup).getOperand().equals(sub)) { unsatisfiableClasses.add(sub.asOWLClass()); } } } return Collections.unmodifiableSet(unsatisfiableClasses); //return new HashSet<OWLClass>(); }
Example #5
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static boolean isNegatedOWLQLRHSConcept(OWLClassExpression cl) { ClassExpressionType type = cl.getNNF().getClassExpressionType(); return type.equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) || type.equals(ClassExpressionType.OBJECT_ALL_VALUES_FROM) || type.equals(ClassExpressionType.DATA_ALL_VALUES_FROM); }
Example #6
Source File: WEKAOntologyConnector.java From AILibs with GNU Affero General Public License v3.0 | 4 votes |
/** * Get the list of ancestors from most general to most specific concept up until * the specified concept including the specified child and highest concept. * * @param algorithm * The child algorithm * @param until * The highest ancestor * @return The ancestors of the child algorithm from the highest ancestor to the * child algorithm itself */ protected List<String> getAncestorsOfAlgorithmUntil(String algorithm, String until) { // Get the individual represented by the algorithm OWLNamedIndividual algorithmAsIndividual = dataFactory.getOWLNamedIndividual(getAsOntologyElement(algorithm)); // Get ancestors ArrayList<OWLClass> ancestors = new ArrayList<>(); ontology.classAssertionAxioms(algorithmAsIndividual).findFirst().ifPresent(algorithmClass -> ancestors.add(algorithmClass.getClassExpression().asOWLClass())); for (int i = 0; i < ancestors.size(); i++) { // If we have found the last element, stop if (ancestors.get(ancestors.size() - 1).getIRI().getShortForm().equals(until)) { break; } int previousAncestorSize = ancestors.size(); ontology.subClassAxiomsForSubClass(ancestors.get(i)) .filter(axiom -> axiom.getSuperClass().getClassExpressionType() == ClassExpressionType.OWL_CLASS) .forEach(axiom -> { OWLClass toAdd = axiom.getSuperClass().asOWLClass(); ancestors.add(toAdd); }); // If we have not added an element if (includeEqualSuperClasses && ancestors.size() == previousAncestorSize) { ontology.equivalentClassesAxioms(ancestors.get(i)).forEach(axiom -> axiom.classExpressions().forEach(elem -> { if (!ancestors.contains(elem.conjunctSet().findFirst().get().asOWLClass())) { ancestors.add(elem.conjunctSet().findFirst().get().asOWLClass()); } }) ); } } // Get names and invert order List<String> ancestorNames = new ArrayList<>(); for (int i = ancestors.size() - 1; i >= 0; i--) { String ancestorName = ancestors.get(i).getIRI().getShortForm(); if (ancestorName.equals(until)) { ancestorNames.add(ancestorName); } } ancestorNames.add(algorithmAsIndividual.getIRI().getShortForm()); return ancestorNames; }
Example #7
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public boolean isSubClass(OWLClassExpression sub, OWLClassExpression sup) { // if sup is equivalent to Top return true if (sup.isOWLThing()) { return true; } if (sup.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) && ( ((OWLObjectComplementOf) sup).getOperand().isOWLNothing() || getUnsatisfiableNamedClasses().contains(((OWLObjectComplementOf) sup).getOperand()) ) ) { return true; } // // if sub is equivalent to Bottom return true if (sub.isOWLNothing() || getUnsatisfiableNamedClasses().contains(sub)) { return true; } if (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF) && ((OWLObjectComplementOf) sub).getOperand().isOWLThing()) { return true; } if ( (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM) || sub.getClassExpressionType().equals(ClassExpressionType.DATA_SOME_VALUES_FROM)) && (((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomObjectProperty() ||((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomDataProperty() || getUnsatisfiableProperties().contains(((OWLQuantifiedRestriction) sub).getProperty()))) { return true; } // // check that tbox union {subclass(NC, sub), sublcass(NC, not(sup)), NC(Nind)} // is inconsistent. NC: new concept, Nind: new individual List<OWLAxiom> newAxioms = new LinkedList<OWLAxiom>(); NormalizedOWLQLTbox ret = this;//copy(); OWLClass newConcept = ret.getNormalizer().createNewNamedClass(); newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sub.getNNF())); newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sup.getComplementNNF())); List<OWLAxiom> newNonOWLQLAxioms = new LinkedList<OWLAxiom>(); Set<OWLAxiom> normalizedAxioms = ret.getNormalizer().toQLNormalForm(newAxioms, newNonOWLQLAxioms); if (!newNonOWLQLAxioms.isEmpty()) { throw new RuntimeException("Both concepts must be OWL QL valid concepts"); } List<OWLSubClassOfAxiom> deltaNegIncAx = new LinkedList<OWLSubClassOfAxiom>(); List<OWLDisjointObjectPropertiesAxiom> deltaNegObjSubPropAx = new LinkedList<OWLDisjointObjectPropertiesAxiom>(); List<OWLDisjointDataPropertiesAxiom> deltaNegDataSubPropAx = new LinkedList<OWLDisjointDataPropertiesAxiom>(); List<OWLSubClassOfAxiom> deltaPosIncAx = new LinkedList<OWLSubClassOfAxiom>(); List<OWLSubPropertyAxiom> deltaPosSubPropAx = new LinkedList<OWLSubPropertyAxiom>(); organizeTboxAxioms(normalizedAxioms, deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx,deltaPosIncAx, deltaPosSubPropAx, new HashSet<OWLObjectProperty>(), new HashSet<OWLObjectProperty>(), new HashMap<String, Set<OWLSubClassOfAxiom>>(), new HashMap<String, Set<OWLSubPropertyAxiom>>()); // inconsistent iff subclass(NC, not(NC)) is in the negative closure OWLAxiom inconsistencyWitness = fac.getOWLSubClassOfAxiom(newConcept, newConcept.getComplementNNF()); Set<OWLAxiom> newNegClos = ret.computeNegativeInclusionClosure(deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx, deltaPosIncAx, deltaPosSubPropAx, inconsistencyWitness); //assert newNegClos == null || !newNegClos.contains(inconsistencyWitness) : newNegClos; // return newNegClos == null; }