Skip to content

Commit

Permalink
Also use IRI to disambiguate properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaoverton committed Nov 13, 2024
1 parent 662ff99 commit 4cbc5ef
Showing 1 changed file with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,22 @@ public OWLDataProperty getOWLDataProperty(@Nonnull String name) {
if (iri != null) {
return dataFactory.getOWLDataProperty(iri);
}
// prevent punning
if (!objectProperties.containsKey(name)) {
if (ioHelper != null) {
iri = ioHelper.createIRI(name);
if (iri != null) {
OWLDataProperty owlDataProperty = dataFactory.getOWLDataProperty(iri);
dataProperties.put(name, iri);
return owlDataProperty;
}
if (ioHelper != null) {
// When the Manchester parser sees "R some X"
// it can't tell whether R is a DataProperty or an ObjectProperty,
// so it tries getOWLDataProperty() first,
// then getOWLObjectProperty().
// We have to check that this name is not an ObjectProperty
// before we create a new DataProperty.
// We check both the name and the IRI.
iri = ioHelper.createIRI(name);
if (objectProperties.containsKey(name) || objectProperties.containsValue(iri)) {
return null;
}
if (iri != null) {
OWLDataProperty owlDataProperty = dataFactory.getOWLDataProperty(iri);
dataProperties.put(name, iri);
return owlDataProperty;
}
}
return null;
Expand Down Expand Up @@ -473,15 +480,21 @@ public OWLObjectProperty getOWLObjectProperty(@Nonnull String name) {
if (iri != null) {
return dataFactory.getOWLObjectProperty(iri);
}
// prevent punning
if (!dataProperties.containsKey(name)) {
if (ioHelper != null) {
iri = ioHelper.createIRI(name);
if (iri != null) {
OWLObjectProperty owlObjectProperty = dataFactory.getOWLObjectProperty(iri);
objectProperties.put(name, iri);
return owlObjectProperty;
}
if (ioHelper != null) {
// When the Manchester parser sees "R some X"
// it can't tell whether R is a DataProperty or an ObjectProperty,
// so it tries getOWLDataProperty() first,
// then getOWLObjectProperty().
// To be safe, we first check that this name is not a DataProperty.
// We check both the name and the IRI.
iri = ioHelper.createIRI(name);
if (dataProperties.containsKey(name) || dataProperties.containsValue(iri)) {
return null;
}
if (iri != null) {
OWLObjectProperty owlObjectProperty = dataFactory.getOWLObjectProperty(iri);
objectProperties.put(name, iri);
return owlObjectProperty;
}
}
return null;
Expand Down

0 comments on commit 4cbc5ef

Please sign in to comment.