protected void writePropertyCharacteristic(OWLXMLVocabulary v, OWLAxiom ax, OWLPropertyExpression prop) { writeAxiomStart(v, ax); prop.accept(this); writeAxiomEnd(); }
public OWLProperty getNamedProperty(OWLPropertyExpression propexp) { OWLProperty ret; if (!propexp.isAnonymous()) { if (propexp.isDataPropertyExpression()) { ret = ((OWLDataPropertyExpression) propexp).asOWLDataProperty();; } else { ret = ((OWLObjectPropertyExpression) propexp).asOWLObjectProperty(); } } else { assert propexp.isObjectPropertyExpression(); ret = ((OWLObjectPropertyExpression) propexp).getNamedProperty(); } return ret; }
/** * Gets the classes which have been asserted to be disjoint with this class by axioms in the * specified ontology. * * @param e entity * @param ontology The ontology to search for disjoint class axioms * @return A {@code Set} of {@code OWLClassExpression}s that represent the disjoint classes of * this class. */ public static <P extends OWLPropertyExpression> Stream<P> getDisjointProperties(P e, OWLOntology ontology) { if (e.isObjectPropertyExpression()) { return Searcher .different(ontology.disjointObjectPropertiesAxioms(e.asObjectPropertyExpression())); } if (e.isDataPropertyExpression()) { return Searcher.different(ontology.disjointDataPropertiesAxioms((OWLDataProperty) e)); } // else e must have been an annotation property. No disjoints on those return empty(); }
public boolean isSubProperty(OWLPropertyExpression normalizedSub, OWLPropertyExpression normalizedSup) { if (normalizedSub.isObjectPropertyExpression() ^ normalizedSup.isDataPropertyExpression()) { return false; } if (normalizedSub.isObjectPropertyExpression()) { return objPropTaxo.isSubsumedBy(normalizedSub, normalizedSup); } else { return dataPropTaxo.isSubsumedBy(normalizedSub, normalizedSup); } }
public Set<P> getChildren(P object) { if (object.equals(getRoot())){ return Collections.unmodifiableSet(subPropertiesOfRoot); } final Set<P> result = new HashSet<P>(); for (E subProp : object.getSubProperties(ontologies)){ // Don't add the sub property if it is a parent of // itself - i.e. prevent cycles if (!subProp.isAnonymous() && !getAncestors((P)subProp).contains(subProp)) { result.add((P)subProp); } } return result; }
private Set<OntologyAxiomPair> parseDisjointProperties() { String section = consumeToken(); if (!DISJOINT_PROPERTIES.matches(section)) { throw new ExceptionBuilder().withKeyword(DISJOINT_PROPERTIES).build(); } Set<OWLOntology> ontologies = getOntologies(); Set<OWLAnnotation> annotations = parseAnnotations(); Set<OWLPropertyExpression> props = parsePropertyList(); Set<OntologyAxiomPair> pairs = new HashSet<>(); OWLAxiom propertiesAxiom; if (props.iterator().next().isObjectPropertyExpression()) { Set<OWLObjectPropertyExpression> ope = new HashSet<>(); props.forEach(pe -> ope.add(pe.asObjectPropertyExpression())); propertiesAxiom = df.getOWLDisjointObjectPropertiesAxiom(ope, annotations); } else { Set<OWLDataPropertyExpression> dpe = new HashSet<>(); props.forEach(pe -> dpe.add(pe.asDataPropertyExpression())); propertiesAxiom = df.getOWLDisjointDataPropertiesAxiom(dpe, annotations); } for (OWLOntology ont : ontologies) { pairs.add(new OntologyAxiomPair(ont, propertiesAxiom)); } return pairs; }
public Set<P> getUnfilteredChildren(P object) { // getReadLock().lock(); ontologySetReadLock.lock(); try { if (object.equals(getRoot())) { return Collections.unmodifiableSet(subPropertiesOfRoot); } final Set<P> result = new HashSet<>(); for (E subProp : getSubProperties(object, ontologies)) { // Don't add the sub property if it is a parent of // itself - i.e. prevent cycles if (!subProp.isAnonymous() && !getAncestors((P) subProp).contains(subProp)) { result.add((P) subProp); } } return result; } finally { ontologySetReadLock.unlock(); // getReadLock().unlock(); } }
public boolean isSubProperty(OWLPropertyExpression sub, OWLPropertyExpression sup) { if (sub.isDataPropertyExpression() ^ sup.isDataPropertyExpression()) { return false; if (sub.isOWLBottomDataProperty() || sub.isOWLBottomObjectProperty() || getUnsatisfiableProperties().contains(sub)) { return true; if (sup.isOWLTopDataProperty() || sup.isOWLTopObjectProperty()) { return true; if (sub.isObjectPropertyExpression()) { OWLObjectPropertyExpression objSub = (OWLObjectPropertyExpression) sub; OWLObjectPropertyExpression objSup = (OWLObjectPropertyExpression) sup; if (sub.isDataPropertyExpression()) { OWLDataProperty newProp = ret.getNormalizer().createNewDataProperty(); newAxioms.add(fac.getOWLSubDataPropertyOfAxiom(newProp,(OWLDataPropertyExpression) sub));
@Override public Set<OWLPropertyExpression> getToldSubsumers( OWLPropertyExpression sub) { if (!sub.isAnonymous()) { Set<OWLPropertyExpression> ret = new HashSet<OWLPropertyExpression>(); Set<? extends OWLSubPropertyAxiom> axioms;// = new HashSet<? extends OWLSubPropertyAxiom>(); if (sub.isObjectPropertyExpression()) { axioms = tbox.getNormalizedOntology().getObjectSubPropertyAxiomsForSubProperty( (OWLObjectPropertyExpression) sub); } else if (!sub.isAnonymous()) { axioms = tbox.getNormalizedOntology().getDataSubPropertyAxiomsForSubProperty( ((OWLDataPropertyExpression) sub).asOWLDataProperty()); } else { axioms = Collections.EMPTY_SET; } if (axioms!=null) { for (OWLSubPropertyAxiom ax: axioms) { assert ax.getSubProperty().equals(sub) : ax+"\n"+sub; ret.add(ax.getSuperProperty()); } } return ret; } return Collections.EMPTY_SET; }
@Override public Set<OWLObjectPropertyExpression> getObjectPropertyExpressions() { Set<OWLObjectPropertyExpression> props = new TreeSet<>(); for (OWLPropertyExpression prop : propertyExpressions) { if (prop.isObjectPropertyExpression()) { props.add((OWLObjectPropertyExpression) prop); } } return props; }
public Set<OWLPropertyExpression> getAllSubproperties( OWLPropertyExpression roleSup) { Set<OWLPropertyExpression> subs = new HashSet<OWLPropertyExpression>(); for (OWLPropertyExpression sub : roleSup.isDataPropertyExpression()? dataPropTaxo.getSubsumeesOrSelf(roleSup) : objPropTaxo.getSubsumeesOrSelf(roleSup)) { if (!sub.isAnonymous()) { subs.add(sub); } else { //OWLObjectProperty op = ((OWLObjectPropertyExpression) c).getNamedProperty(); //fac.getOWLObjectProperty(IRI.create(sub.getInverse().getName().getAFun().getName())); //if (oprops.contains(op)) { subs.add(sub); } //else { // do nothing: inverse of a create role R, where R is defined as equivalent to the inverse of an existing role //} } } subs.remove(dataPropTaxo.getBottom()); subs.remove(objPropTaxo.getBottom()); subs.remove(fac.getOWLObjectInverseOf((OWLObjectPropertyExpression) objPropTaxo.getBottom()).getSimplified()); return subs; }
@Override public Set<OWLDataPropertyExpression> getDataPropertyExpressions() { Set<OWLDataPropertyExpression> props = new TreeSet<>(); for (OWLPropertyExpression prop : propertyExpressions) { if (prop.isDataPropertyExpression()) { props.add((OWLDataPropertyExpression) prop); } } return props; }
public Set<P> getParents(P object) { if (object.equals(getRoot())){ return Collections.emptySet(); } Set<P> result = new HashSet<P>(); for (E prop : object.getSuperProperties(ontologies)) { if (!prop.isAnonymous()) { result.add((P) prop); } } if (result.isEmpty() && isReferenced(object)){ result.add(getRoot()); } return result; }
public Set<P> getEquivalents(P object) { Set<P> result = new HashSet<P>(); Set<P> ancestors = getAncestors(object); if (ancestors.contains(object)) { for (P anc : ancestors) { if (getAncestors(anc).contains(object)) { result.add(anc); } } } for (E prop : object.getEquivalentProperties(ontologies)) { if (!prop.isAnonymous()) { result.add((P)prop); } } result.remove(object); return result; }
protected Set<OWLPropertyExpression> getCommunSubproperty(Set<OWLPropertyExpression> props) { Set<OWLPropertyExpression> communSubsumees = null; for (OWLPropertyExpression propRole: props) { Set<OWLPropertyExpression> subs = new HashSet<OWLPropertyExpression> (propRole.isDataPropertyExpression()? dataPropTaxo.getSubsumeesOrSelf(propRole) : objPropTaxo.getSubsumeesOrSelf(propRole)); if (propRole.isDataPropertyExpression()) { subs.removeAll(dataPropTaxo.getBottomNode().getEquivalentElements()); } else { assert propRole.isObjectPropertyExpression() : propRole; subs.removeAll(objPropTaxo.getBottomNode().getEquivalentElements()); } if (communSubsumees == null) { communSubsumees = new HashSet<OWLPropertyExpression>(); communSubsumees.addAll(subs); } else { communSubsumees.retainAll(subs); } if (communSubsumees.isEmpty()) { return Collections.EMPTY_SET; } } return communSubsumees == null? new HashSet<OWLPropertyExpression>(): communSubsumees; }
private Set<OntologyAxiomPair> parseNaryEquivalentProperties() { String tok = consumeToken(); if (!EQUIVALENT_PROPERTIES.matches(tok)) { throw new ExceptionBuilder().withKeyword(EQUIVALENT_PROPERTIES).build(); } Set<OWLOntology> ontologies = getOntologies(); Set<OWLAnnotation> annotations = parseAnnotations(); Set<OWLPropertyExpression> properties = parsePropertyList(); OWLAxiom propertyAxiom; if (properties.iterator().next().isObjectPropertyExpression()) { Set<OWLObjectPropertyExpression> ope = new HashSet<>(); properties.forEach(pe -> ope.add(pe.asObjectPropertyExpression())); propertyAxiom = df.getOWLEquivalentObjectPropertiesAxiom(ope, annotations); } else { Set<OWLDataPropertyExpression> dpe = new HashSet<>(); properties.forEach(pe -> dpe.add(pe.asDataPropertyExpression())); propertyAxiom = df.getOWLEquivalentDataPropertiesAxiom(dpe, annotations); } Set<OntologyAxiomPair> pairs = new HashSet<>(); for (OWLOntology ont : ontologies) { pairs.add(new OntologyAxiomPair(ont, propertyAxiom)); } return pairs; }
public Set<P> getChildren(P object) { if (object.equals(getRoot())){ return Collections.unmodifiableSet(subPropertiesOfRoot); } final Set<P> result = new HashSet<>(); for (E subProp : EntitySearcher.getSubProperties(object, getOntologies())){ // Don't add the sub property if it is a parent of // itself - i.e. prevent cycles if (!subProp.isAnonymous() && !getAncestors((P)subProp).contains(subProp)) { result.add((P)subProp); } } return result; }
/** * returns the key associated with a property expression * @param pe * @return */ public static String getKey(OWLPropertyExpression pe) { if (pe.isObjectPropertyExpression()) { pe = ((OWLObjectPropertyExpression) pe).getSimplified(); } if (!pe.isAnonymous()) { return ((OWLNamedObject) pe).getIRI().toString(); } else { OWLObjectInverseOf ope = (OWLObjectInverseOf) pe; OWLObjectProperty op = (OWLObjectProperty) ope.getInverse(); return op.getIRI().toString(); } }
@Override @SuppressWarnings("rawtypes") // this is necessary to avoid java 6 issues public Set<OWLObjectPropertyExpression> getObjectPropertyExpressions() { Set<OWLObjectPropertyExpression> props = new TreeSet<OWLObjectPropertyExpression>(); for (OWLPropertyExpression prop : propertyExpressions) { if (prop.isObjectPropertyExpression()) { props.add((OWLObjectPropertyExpression) prop); } } return props; }
public Set<OWLDataPropertyExpression> getDataPropertyExpressions() { Set<OWLDataPropertyExpression> props = new TreeSet<OWLDataPropertyExpression>(); for(OWLPropertyExpression prop : propertyExpressions) { if(prop.isDataPropertyExpression()) { props.add((OWLDataPropertyExpression) prop); } } return props; }