@Override public Set<OWLObjectPropertyExpression> getObjectPropertyExpressions() { Set<OWLObjectPropertyExpression> props = new TreeSet<>(); for (OWLPropertyExpression prop : propertyExpressions) { if (prop.isObjectPropertyExpression()) { props.add((OWLObjectPropertyExpression) prop); } } return props; }
@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<OWLObjectPropertyExpression> getObjectPropertyExpressions() { Set<OWLObjectPropertyExpression> props = new TreeSet<OWLObjectPropertyExpression>(); for(OWLPropertyExpression prop : propertyExpressions) { if(prop.isObjectPropertyExpression()) { props.add((OWLObjectPropertyExpression) prop); } } return props; }
/** * @return this instance cast as an OWLObjectPropertyExpression */ default OWLObjectPropertyExpression asObjectPropertyExpression() { if (isObjectPropertyExpression()) { return (OWLObjectPropertyExpression) this; } throw new ClassCastException( getClass().getName() + "is not an OWLObjectPropertyExpression"); }
/** * @return this instance cast as an OWLObjectPropertyExpression */ default OWLObjectPropertyExpression asObjectPropertyExpression() { if (isObjectPropertyExpression()) { return (OWLObjectPropertyExpression) this; } throw new ClassCastException( getClass().getName() + "is not an OWLObjectPropertyExpression"); }
/** * @return this instance cast as an OWLObjectPropertyExpression */ default OWLObjectPropertyExpression asObjectPropertyExpression() { if (isObjectPropertyExpression()) { return (OWLObjectPropertyExpression) this; } throw new ClassCastException( getClass().getName() + "is not an OWLObjectPropertyExpression"); }
protected static OWLPropertyExpression getSimplified(OWLPropertyExpression pe) { if (pe.isObjectPropertyExpression()) { pe = ((OWLObjectPropertyExpression) pe).getSimplified(); } return pe; }
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); } }
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 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; }
/** * 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(); } }
/** * Gets the properties which are asserted to be sub-properties of this property in the specified * ontology. * * @param e entity * @param ontology The ontology to be examined for SubProperty axioms. * @return A set of properties such that for each property {@code p} in the set, it is the case * that {@code ontology} contains an {@code SubPropertyOf(p, this)} axiom where * {@code this} refers to this property. * @since 3.2 */ public static <P extends OWLPropertyExpression> Stream<P> getSuperProperties(P e, OWLOntology ontology) { if (e.isObjectPropertyExpression()) { return Searcher.sup(ontology.axioms(subObjectPropertyWithSub, e, EXCLUDED)); } if (e.isDataPropertyExpression()) { return Searcher.sup(ontology.axioms(subDataPropertyWithSub, e, EXCLUDED)); } return Searcher.sup(ontology.axioms(subAnnotationWithSub, e, EXCLUDED)); }
/** * Gets the properties which are asserted to be sub-properties of this property in the specified * ontology. * * @param e entity * @param ontology The ontology to be examined for SubProperty axioms. * @return A set of properties such that for each property {@code p} in the set, it is the case * that {@code ontology} contains an {@code SubPropertyOf(p, this)} axiom where * {@code this} refers to this property. * @since 3.2 */ public static <P extends OWLPropertyExpression> Stream<P> getSuperProperties(P e, OWLOntology ontology) { if (e.isObjectPropertyExpression()) { return Searcher.sup(ontology.axioms(subObjectPropertyWithSub, e, EXCLUDED)); } if (e.isDataPropertyExpression()) { return Searcher.sup(ontology.axioms(subDataPropertyWithSub, e, EXCLUDED)); } return Searcher.sup(ontology.axioms(subAnnotationWithSub, e, EXCLUDED)); }
/** * 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(); }
/** * 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(); }
/** * Gets the properties which are asserted to be sub-properties of this property in the specified * ontology. * * @param e entity * @param ontology The ontology to be examined for SubProperty axioms. * @return A set of properties such that for each property {@code p} in the set, it is the case * that {@code ontology} contains an {@code SubPropertyOf(p, this)} axiom where * {@code this} refers to this property. * @since 3.2 */ public static <P extends OWLPropertyExpression> Stream<P> getSubProperties(P e, OWLOntology ontology) { if (e.isObjectPropertyExpression()) { return Searcher.sub(ontology.axioms(subObjectPropertyWithSuper, e, EXCLUDED)); } if (e.isDataPropertyExpression()) { return Searcher.sub(ontology.axioms(subDataPropertyWithSuper, e, EXCLUDED)); } return Searcher.sub(ontology.axioms(subAnnotationWithSuper, e, EXCLUDED)); }
/** * 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(); }
/** * Gets the properties which are asserted to be sub-properties of this property in the specified * ontology. * * @param e entity * @param ontology The ontology to be examined for SubProperty axioms. * @return A set of properties such that for each property {@code p} in the set, it is the case * that {@code ontology} contains an {@code SubPropertyOf(p, this)} axiom where * {@code this} refers to this property. * @since 3.2 */ public static <P extends OWLPropertyExpression> Stream<P> getSubProperties(P e, OWLOntology ontology) { if (e.isObjectPropertyExpression()) { return Searcher.sub(ontology.axioms(subObjectPropertyWithSuper, e, EXCLUDED)); } if (e.isDataPropertyExpression()) { return Searcher.sub(ontology.axioms(subDataPropertyWithSuper, e, EXCLUDED)); } return Searcher.sub(ontology.axioms(subAnnotationWithSuper, e, EXCLUDED)); }
public String getName(OWLPropertyExpression propexp) { String name; if (!propexp.isAnonymous()) { if (propexp.isDataPropertyExpression()) { name = ((OWLDataPropertyExpression) propexp).asOWLDataProperty().getIRI().toString(); } else { name = ((OWLObjectPropertyExpression) propexp).asOWLObjectProperty().getIRI().toString(); } } else { assert propexp.isObjectPropertyExpression(); name = ((OWLObjectPropertyExpression) propexp).getNamedProperty().getIRI().toString(); } return name; }
public String getName(OWLPropertyExpression propexp) { String name; if (!propexp.isAnonymous()) { if (propexp.isDataPropertyExpression()) { name = ((OWLDataPropertyExpression) propexp).asOWLDataProperty().getIRI().toString(); } else { name = ((OWLObjectPropertyExpression) propexp).asOWLObjectProperty().getIRI().toString(); } } else { assert propexp.isObjectPropertyExpression(); name = ((OWLObjectPropertyExpression) propexp).getNamedProperty().getIRI().toString(); } return name; } /**