/** * Counts occurrences of \forall in description. * @param description A description. * @return Number of \forall occurrences. */ public static int getForallOccurences(OWLClassExpression description) { int count = 0; for (OWLClassExpression expression : description.getNestedClassExpressions()) { if(expression instanceof OWLObjectAllValuesFrom) { count++; } } return count; }
Set<OWLClassExpression> nestedClassExpressions = description.getNestedClassExpressions(); for (OWLClassExpression expression : nestedClassExpressions) {
/** * Returns true if the same property is used twice in an object some * restriction, e.g. (EXISTS r.A1 AND A2 AND EXISTS r.A3) returns true, * while (A1 OR A2) and (EXISTS r.A1 AND A2 AND EXISTS s.A3) return false. * Note that the method does not work recursively, e.g. it return false * for EXISTS r.(EXISTS r.A1 AND A2 AND EXISTS r.A3). * * @param d OWLClassExpression to test. * @return See description. */ public static boolean containsDoubleObjectSomeRestriction(OWLClassExpression d) { Set<OWLObjectPropertyExpression> roles = new HashSet<>(); for(OWLClassExpression c : d.getNestedClassExpressions()) { if(c instanceof OWLObjectSomeValuesFrom) { OWLObjectPropertyExpression role = ((OWLObjectSomeValuesFrom)c).getProperty(); boolean roleExists = !roles.add(role); if(roleExists) return true; } } return false; } }
private boolean containsObjectAllRestriction(OWLClassExpression d){ for(OWLClassExpression child : d.getNestedClassExpressions()){ if(child.getClassExpressionType() == ClassExpressionType.OBJECT_ALL_VALUES_FROM){ return true; } } return false; } }
+ expr.getNestedClassExpressions().size()); for (OWLClassExpression expr2 : expr.getNestedClassExpressions()) { Logger.getLogger(OwlUtility.class).debug( indent + " class expr = " + expr2);
public static RDFResourceTree materializePropertyDomains(RDFResourceTree tree, AbstractReasonerComponent reasoner) { RDFResourceTree newTree = new RDFResourceTree(tree.getData()); Consumer<OWLClass> addTypeChild = (cls) -> newTree.addChild(new RDFResourceTree(OwlApiJenaUtils.asNode(cls)), RDF.type.asNode()); tree.getEdges().forEach(edge -> { List<RDFResourceTree> children = tree.getChildren(edge); // add existing children children.forEach(child -> { RDFResourceTree newChild = materializePropertyDomains(child, reasoner); newTree.addChild(newChild, edge); }); // add the rdf:type statements for the property domain(s) OWLClassExpression dom = reasoner.getDomain(OwlApiJenaUtils.asOWLEntity(edge, EntityType.OBJECT_PROPERTY)); if(!dom.isAnonymous() && !dom.isOWLThing()) { addTypeChild.accept(dom.asOWLClass()); } else { if(dom.getClassExpressionType() == ClassExpressionType.OBJECT_INTERSECTION_OF) { dom.getNestedClassExpressions().stream() .filter(ce -> !ce.isAnonymous()) .map(OWLClassExpression::asOWLClass) .forEach(addTypeChild); } } }); return newTree; }
} else { if(type.getClassExpressionType() == ClassExpressionType.OBJECT_INTERSECTION_OF) { type.getNestedClassExpressions().stream() .filter(ce -> !ce.isAnonymous()) .map(OWLClassExpression::asOWLClass)