Login  Register

Finding differences between two ontologies

classic Classic list List threaded Threaded
4 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Finding differences between two ontologies

Stefan
1 post
Hi,

I'm trying to get all differences between two ontologies. (Specifically, the same ontology loaded before and after a modification.) For this I used rdflibs set operations as described here: https://rdflib.readthedocs.io/en/stable/_modules/rdflib/graph.html

I tried having my ontologies in different worlds and in the same world, but in both cases I got a lot more results than I should have. I then tried subtracting the graph of the ontology from itself like this:

diff = or2.default_world.as_rdflib_graph() - or2.default_world.as_rdflib_graph()

for bla in diff:
    print(bla)

... and I did not get an empty result, as I would expect, but still something that looked like the entire triple store. (Same result using XOR ^.) So I wondered if this may be due to owlready's implementation of the rdfgraph? I remember there being issues with that before.
If not, what else can I try?


Also, this is likely my last post here. I would like to thank you for the *excellent* support this package receives!

-Stefan
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Finding differences between two ontologies

Jiba
Administrator
1183 posts
Hi,

I tried with a few ontologies of mine, using 2 different worlds, but I get no difference.

You may be interested by the script "ntriples_diff.py" in the sources of Owlready. It can be used to diff NTriple files, and it is used for testing Owlready. If you save your ontologies as NTriples files, you can use it to diff the files.

Jiba

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Finding differences between two ontologies

phiofx
13 posts
Looking at the script (and not yet completely up to speed with either owl or owlready :-) it looks like this is finding differences that involve the renaming of classes / properties? I am looking into the subject of "diffing" ontologies and I found also the concept of structural equivalence (identifying when the overall graph structure has changed). Both seem useful to have.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Finding differences between two ontologies

Jiba
Administrator
1183 posts
Yes, the script is comparing NTriples files. Small differences (e.g. different names for blank nodes, different triple orders, etc) are not considered. However, more complex structural differences are (e.g. different OWL pattern that are semantically equivalent but different in their syntax, leading to different RDF triples).

Jiba