Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ontology IRI is decoded incorrectly if annotation property subject and object use the ontology IRI #1181

Open
vChavezB opened this issue Nov 24, 2023 · 6 comments
Assignees
Labels
Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken Type: OWL API Bug A bug in the OWL API that is manifested in Protege. Should be reported on the OWL API tracker

Comments

@vChavezB
Copy link

vChavezB commented Nov 24, 2023

I found out that if the ontology is annotated with rdfs:isDefinedBy with an IRI value equal to the ontology IRI then Protege Editor displays the ontology iri as if was the last imported ontology.

How to reproduce

  1. Create a turtle file with this ontology
@prefix : <http://www.ontology_iri#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix untitled-ontology-232: <http://www.semanticweb.org/vc9917e/ontologies/2023/10/untitled-ontology-232#> .
@prefix www.ontology_iri_version: <http://www.ontology_iri_version#> .
@base <http://www.ontology_iri> .

<http://www.ontology_iri> rdf:type owl:Ontology ;
                           owl:versionIRI <http://www.ontology_iri_version> ;
                           owl:imports <http://www.co-ode.org/ontologies/pizza/2.0.0> ;
                           rdfs:isDefinedBy <http://www.ontology_iri> .

###  Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi

Open the file locally in protege

grafik

@gouttegd
Copy link
Collaborator

This looks like a problem in the OWL API, upstream of Protégé.

Minimal code to reproduce the problem outside of Protégé:

import java.io.File;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class Test {
    public static void main(String[] args) {
        OWLOntologyManager man = OWLManager.createConcurrentOWLOntologyManager();
        try {
            OWLOntology o = man.loadOntologyFromOntologyDocument(new File("sample.ttl"));
            System.out.printf("Ontology ID: %s\n", ontology.getOntologyID().getOntologyIRI().orNull());
        } catch (OWLOntologyCreationException e) {
            e.printStackTrace();
        }
    }
}

This yields the same result as what is shown in Protégé:

Ontology ID: http://www.co-ode.org/ontologies/pizza/2.0.0

Running the same code on a sample file that does not contain the rdfs:isDefinedBy annotation (or if that annotation has a value different from the ontology IRI) yields the normal expected result:

Ontology ID: http://www.ontology_iri

@gouttegd gouttegd self-assigned this Nov 24, 2023
@gouttegd gouttegd added Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken Type: OWL API Bug A bug in the OWL API that is manifested in Protege. Should be reported on the OWL API tracker labels Nov 24, 2023
@gouttegd
Copy link
Collaborator

The problem is not specifically caused by rdfs:isDefinedBy: it seems any annotation can cause the same issue as long as its value is the same as the ontology IRI. For example, this file, with a rdfs:seeAlso annotation, triggers the issue as well:

@prefix : <http://www.ontology_iri#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix www.ontology_iri_version: <http://www.ontology_iri_version#> .
@base <http://www.ontology_iri> .

<http://www.ontology_iri> rdf:type owl:Ontology ;
                           owl:versionIRI <http://www.ontology_iri_version> ;
                           owl:imports <http://www.co-ode.org/ontologies/pizza/2.0.0> ;
                           rdfs:seeAlso <http://www.ontology_iri> .

@gouttegd
Copy link
Collaborator

Seems like an instance of an already reported bug: owlcs/owlapi#1080

@vChavezB
Copy link
Author

Thanks for the info. I think I found the bug in owl api owlcs/owlapi#1080 (comment)

I will wait for a follow up on the owl api project.

@vChavezB
Copy link
Author

Update: I have found the bug and made a pull request owlcs/owlapi#1117

In the meanwhile the PR can be used to manually build the owl api distribution. I also provide the jar file from CI/CD in case anyone else wants to test it in Protege v5.6.3 (i.e. owl api version 4.5.26)

To test it just rename the jar file owlapi-osgidistribution-4.5.26.jar to owlapi-osgidistribution.jar and replace the one in the bundles directory.

@vChavezB vChavezB changed the title Ontology IRI is decoded incorrectly if annotation property rdfs:isDefinedBy is used Ontology IRI is decoded incorrectly if annotation property subject and object use the ontology IRI Nov 26, 2023
@vChavezB
Copy link
Author

The PR I submitted has been accepted to the owlapi. This means that to fix this issue you can build the owlapi (branch version4) locally and replace the owlapi-osgidistribution.jar from the bundles directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken Type: OWL API Bug A bug in the OWL API that is manifested in Protege. Should be reported on the OWL API tracker
Projects
None yet
Development

No branches or pull requests

2 participants