I'm using FuXi.Syntax.InfixOWL in Python to generate an OWL ontology. I want to make all subclasses of a class mutually disjoint, and to do that I'm using the cumbersome owl:disjointWith, specifying it for every subclass. The resulting .owl file is huge and takes forever to load into Protege. Is there any way to do this more concisely? Thanks.

asked 12 Dec '12, 15:15

John%20Peter%20Thompson%20Garc%C3%A9s's gravatar image

John Peter T...
214
accept rate: 0%

edited 13 Dec '12, 09:59


OWL 2 introduces the owl:AllDisjointClasses axiom, by which you can state that classes C1, ..., Cn, for arbitrary n, are pairwise disjoint:

_:x rdf:type owl:AllDisjointClasses .
    owl:members ( C1 ... Cn ) .
link

answered 12 Dec '12, 15:30

Michael%20Schneider's gravatar image

Michael Schn... ♦
6.1k1612
accept rate: 34%

Thanks, but I'm actually looking to figure out how to do this in Python, for instance using rdflib or InfixOWL, in an example similar to this one: http://python-dlp.googlecode.com/files/pomr.py

Suppose I have foo = Class(MY_NS['foo']) and bar = Class(MY_NS['bar'])

So I want a constructor that does something like this:

myDisjointClasses = AllDisjointClasses( [ foo, bar ] )

and then I can get output like yours above when I serialize the graph.

I'd like to know if something like this exists in rdflib, or how to implement it.

(13 Dec '12, 10:17) John Peter T... John%20Peter%20Thompson%20Garc%C3%A9s's gravatar image

BTW, here is what I've tried:

from rdflib import BNode, RDF, Collection
from RDFClosure.AxiomaticTriples import AllDisjointClasses, members

g = Graph()
anode = BNode()
disjoint_siblings = [ ... ] # some list of InfixOWL.Class objects
g.add( ( anode, RDF.type, AllDisjointClasses ) )
g.add( ( anode, members, Collection(g, disjoint_siblings) ) )

When I try to serialize I get this error:

AttributeError: 'Collection' object has no attribute 'replace'
(13 Dec '12, 11:17) John Peter T... John%20Peter%20Thompson%20Garc%C3%A9s's gravatar image

I've figured it out now. Here's what I did:

g = Graph()
anode = BNode()
bnode = BNode()
coll = Collection(g, anode, disjoint_siblings) # Here, disjoint_siblings is a list of URIs
g.add( ( bnode, RDF.type, AllDisjointClasses ) )
g.add( ( bnode, members, anode ) )

The only problem I have with this, though, is that in the serialized XML file, I end up with a lot of descriptions of list configurations with rdf:first and rdf:rest, for every possible configuration of first and rest. This stuff is unnecessary. All I needed was the AllDisjointClasses part. Why is it there?

(13 Dec '12, 18:26) John Peter T... John%20Peter%20Thompson%20Garc%C3%A9s's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×541
×171
×37
×33

Asked: 12 Dec '12, 15:15

Seen: 1,021 times

Last updated: 13 Dec '12, 18:26