OpenEnergyPlatform / ontology

Repository for the Open Energy Ontology (OEO)
Creative Commons Zero v1.0 Universal
106 stars 20 forks source link

Annotations attached to axioms seem to disappear in Protégé #1179

Open markus-rothkoetter opened 2 years ago

markus-rothkoetter commented 2 years ago

Description of the issue

When I open a file with annotations attached to axioms, they are not visible in the UI:

image

However, the annotations are in the corresponding ontology-file. As soon as the file is saved in any way within Protégé (unrelated from certain entities), the annotations are also lost on the file-level:

image

Ideas of solution

I'd be happy, if someone could test whether this issue is reproduceable. (@jannahastings, @MGlauer ? 😉) If it isn't reproduceable, it might be related to my machine.

Steps for testing:

  1. Open e.g. ro-module in a text editor.
  2. Check whether the annotations exist e.g. at RO_0002234
  3. Open the same file in Protégé
  4. Check whether the annotations exist e.g. at RO_0002234
  5. Save file from Protégé
  6. Check whether the annotations disappeared on file-level, too.

Other things I already checked:

l-emele commented 2 years ago

Which exact Protégé version are you using? We had previously some problems (#471, #620) with Protégé that were related to different Protégé versions.

markus-rothkoetter commented 2 years ago

v5.5.0 on Win10 release-version, so there shouldn't be any problems with beta-version etc.

jannahastings commented 2 years ago

@markus-rothkoetter is there a feature branch with the relevant annotations committed so that I could quickly check out your files with my Protege?

markus-rothkoetter commented 2 years ago

@jannahastings You can select any branch, I think. Just cross-checked, if this might be related to my local branch.

Unfortunately, I can reproduce the bug on any branch I tested (including dev) Simply, open e.g. ro-module in Protégé, do an arbitrary edit (e.g. create class, change a letter in editor note or something else) and save from Protégé. Git's diff-view will show that annotations to axioms are lost in that file.

jannahastings commented 2 years ago

@markus-rothkoetter Does it also happen in an OWL file in RDF-XML format? Or is it just the Manchester syntax files? Never mind I realise that the ro-module is in RDF-XML already :-/

jannahastings commented 2 years ago

@markus-rothkoetter I can save the file from Protege without losing annotations on axioms

jannahastings commented 2 years ago

@markus-rothkoetter Did you try just with a simple axiom annotation - just text no URLs?

markus-rothkoetter commented 2 years ago

@jannahastings

Did you try just with a simple axiom annotation - just text no URLs?

The strange thing is that the former annotations aren't visible at all, but new ones show. I'll try with a new vanilla ontology file, if the issue is reproduceable.

markus-rothkoetter commented 2 years ago

We can confirm that this is a bug in Protégé that is reproduceable on different machines with different OS, this means:

Annotations to axioms (InverseOf, SubPropertyOf, potentially more) are lost, when a file is opened and saved from Protégé. This might have resulted in data loss of term tracker item-annotations already and will lead to further data-loss (inevitablely). The actual ontology axioms are NOT affected and therefore save.

The next steps are planned as followed:

markus-rothkoetter commented 2 years ago

During #1197 it seemed like owlapi fills arbitrary axioms at places where they were already lost. Inspect at least at RO_0004009, RO_0002505 and is defined by

markus-rothkoetter commented 2 years ago

There seem to be to different syntax uses for annotating axioms: Syntax 01: image

Syntax 02: image

Maybe this is dependend on the kind of saving format.

AFAIK, there are only axioms affected which use syntax 02

Currently, those are not much: image

Ergo, the problem seems to have a quite limited scope. @jannahastings Syntax 02 is RDF-XML, isn't it? So, is syntax 01 pure Manchester-Syntax then?

l-emele commented 2 years ago

From OEO DEV Meeting 39 (decisions highlighted):

stap-m commented 1 year ago

Please take over this issue @stage1407

stap-m commented 1 year ago

@stage1407 Please add here the next steps we decided on in our meeting yesterday. Please also record your work on the issue here by commenting. Thanks!

stage1407 commented 1 year ago

The next steps are:

  1. Setting up a minimal ontology.
  2. Reproduce the bug on this ontology
  3. Send it to the Protégé developers
stage1407 commented 1 year ago

I noticed an interesting and strange behaviour, when reading the original file and the file to be overwritten. All axioms that were annotated by rdfs:comment were exactly the ones that were not discarded.

This allows a new workaround for us and provides interesting information for the developers of Protege.

stage1407 commented 1 year ago

Here a little example ontology, if anyone wants to try it on their own machine.

Protege will add some lines automatically, but these should be irrelevant. (In detail: It infers from the context that Property must be an Individual and an Annotations.)

<?xml version="1.0"?> <rdf:RDF xmlns="http://www.semanticweb.org/alexander.stage/ontologies/2022/9/untitled-ontology-13#" xml:base="http://www.semanticweb.org/alexander.stage/ontologies/2022/9/untitled-ontology-13" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <owl:Ontology rdf:about="http://www.semanticweb.org/alexander.stage/ontologies/2022/9/untitled-ontology-13"/>

<!-- /////////////////////////////////////////////////////////////////////////////////////// // // Object Properties // /////////////////////////////////////////////////////////////////////////////////////// -->

<!-- http://example.com/ -->

<owl:ObjectProperty rdf:about="http://example.com/Property"> <rdfs:label xml:lang="en">Property</rdfs:label> </owl:ObjectProperty> <owl:Axiom> <owl:annotatedSource rdf:resource="http://example.com/Property"/> <owl:annotatedProperty rdf:resource="http://example.com/Property"/> <owl:annotatedTarget rdf:resource="http://example.com/Property"/>

<!-- Here can be written more and it disappears --> </owl:Axiom> </rdf:RDF>

stage1407 commented 1 year ago

I added these lines below and they confirm my assumption, with rdfs:label from my second comment.

<owl:ObjectProperty rdf:about="http://example.com/Property2"> <rdfs:label xml:lang="en"> Property </rdfs:label> </owl:ObjectProperty> <owl:Axiom> <owl:annotatedSource rdf:resource="http://example.com/Property"/> <owl:annotatedProperty rdf:resource="http://example.com/Property"/> <owl:annotatedTarget rdf:resource="http://example.com/Property"/> <rdfs:comment> Yippee, I still exist </rdfs:comment> </owl:Axiom>

fabianneuhaus commented 1 year ago

After a short discussion Alexander and I agreed on the following next steps:

stage1407 commented 1 year ago

"One strategy to avoid the problem is to add annotations to the axioms [...]"

I think this should work, but I tested this only with the Annotation Property: rdfs:comment. So, with rdfs:comment you are on the save side.

stage1407 commented 1 year ago

Report: I read the OWL API Introduction, Documentation and Tutorial. Then I tried to include the OWL API in a Java test project. Unfortunately it seems to have problems to include this specific library. (Cannot resolve import) Then I tried it in the IDEs: Visual Studio Code and Eclipse.

Next try would be via IntelliJ, as this offers more detailed ways to include libraries.

I also went through the issues of the OWL API on Github. The issue we are having is not documented there.

Next steps:

fabianneuhaus commented 1 year ago

If you have problem to use the OWL API, you could ask Simon Flügel who used it recently for his BA thesis. His code is available here, if you want to have a look https://github.com/gavel-tool/python-gavel-owl/tree/dev/java/src

(Part of the system was developed by Anna Kleinau.)

stage1407 commented 1 year ago

The OWL API is now correctly integrated into a test project.

stage1407 commented 1 year ago

The next step will be to write a test project to find out if the error is caused by Protege or the OWL API.

stage1407 commented 1 year ago

Now, I've written a test project and got a strange exception.

NoClassDefFoundException: com/google/inject/Provider

Thereupon I tried a little bit back and forth, but without success. Now I contacted Simon. Maybe he has some ideas about this.

stage1407 commented 1 year ago

I have found a jar of the OWL API 5.1.5 (via jar-downloader) But the apibinding package is missing, which I need to use the OWLManager. A little bit confusing, because the current documented version is the 4.5.19.

Tomorrow I will try to find out, whether I can patch this somehow or I have to setup a whole MavenProject for it..

stap-m commented 1 year ago

@stage1407 did you try out the script of @sfluegel05 ?

stage1407 commented 1 year ago

@stap-m I could copy his MavenProject, but I don't know about side-effects but less effort than my ideas. I will try that.

stage1407 commented 1 year ago

That's it! Now we have results.

The OWL API changes some things in the ontology, but no axioms or other information disappear.

The disappearance of axioms seems to be triggered by Protege.

stage1407 commented 1 year ago

Input of the first Test:

image

Output of the first Test:

image
stage1407 commented 1 year ago

Next steps:

  1. design a test example of a more realistic ontology in Manchester syntax. Whereby it should no longer be about such special triples like (p p p .) and the example should be closer to the actual bug .

  2. add a comment to each axiom, what it means in the natural language (maybe a separate issue for that?)

  3. if comment is missing for an axiom, let the build tests of the ontology report warnings in Github or fail directly (maybe a separate issue for that, too..)

stage1407 commented 1 year ago

TODO:

stage1407 commented 1 year ago

The way I read the discussion, it's a similar problem, but it won't really solve this problem because the point here is to add a comment to each axiom so it doesn't disappear. AFAIK this does not happen for each import But my last stand was that all axioms are imported. @stap-m do you know where these axioms are imported from, and by which processes? Then maybe only an already existing script would have to be adjusted a bit, and we would be done.

Otherwise I have to figure it out first.

stage1407 commented 1 year ago

Robot does not provide a direct command to add comments to a dynamic set of axioms, but it is possible to write a program using Robot commands, reading the imported axioms, and creating the comments depending on the axiom in question The alternative would be to program with the OWL API

So we have the following options

I would prefer the first option, since it requires less effort and we would get the same result as with the second option.

stap-m commented 1 year ago

@stap-m do you know where these axioms are imported from, and by which processes? Then maybe only an already existing script would have to be adjusted a bit, and we would be done.

This is the import script for ro-extracted.owl.

stap-m commented 1 year ago

@stage1407 PR #1452 also deals with the extraction script. Please wait for it to be merged.

jamesaoverton commented 1 year ago

A linked issue on the ROBOT tracker led me here. You are definitely experiencing some strange behaviour. I work with OWL annotation axioms every day and do not see them disappear. I would guess that there's a problem with a namespace or strange URL, or with imports. Whatever the underlying problem, adding annotations to every imported axiom can't be the right solution.

If you have a minimal example, I will look at it. The example in comment https://github.com/OpenEnergyPlatform/ontology/issues/1179#issuecomment-1328786054 is not a good example, because it is malformed at line 30: the OWL axiom annotation does not have actual annotation content, so OWLAPI is dropping the annotated* reification triples.

matentzn commented 1 year ago

Typical cause of the problem: No Declaration axiom from the annotation property used in the axiom annotation.