Jena Ontology API and type definitions of classes

53 views
Skip to first unread message

Nils Reiter <reiter@cl.uni-heidelberg.de>

unread,
May 15, 2008, 1:23:23 PM5/15/08
to Music Ontology Specification Group
Hi,

I recently stumbled upon the music ontology, because I was looking for
an interesting ontology for use in a natural language processing
project. Usually, I use Jena (jena.sf.net) to parse and manipulate
ontologies automatically, but I had a problem with the music ontology:
Using the ontology model, Jena came up with only one class (which was
"Sacd"), but my guess is that it was completely random. Using the
default model, Jena found around half of the classes.
I looked into the musicontology code and I found, that the classes are
defined as rdfs:class *and* are typed as owl#class using rdf:type. I
have to admit that I am not that much into owl, rdf, etc. but as I
understand this (http://www.w3schools.com/rdf/rdf_schema.asp),
rdfs:Class is just an abbreviation for rdf:Description and
rdf:type=...rdf-schema#Class -- if that's correct, using rdfs:Class
and rdf:type owl#Class would be double typing ...

I automatically replaced all "rdfs:Class" with "owl:Class" -- and
everything went fine, Jena loads the ontology without a problem.

So if there is no eminent reason to type the classes both using
owl#Class and rdf-schema#Class, I would suggest to define them as
owl#Class only.

Best,
Nils

Yves Raimond

unread,
May 15, 2008, 1:30:51 PM5/15/08
to music-ontology-sp...@googlegroups.com
Hi Nils!

> I recently stumbled upon the music ontology, because I was looking for
> an interesting ontology for use in a natural language processing
> project. Usually, I use Jena (jena.sf.net) to parse and manipulate
> ontologies automatically, but I had a problem with the music ontology:
> Using the ontology model, Jena came up with only one class (which was
> "Sacd"), but my guess is that it was completely random. Using the
> default model, Jena found around half of the classes.
> I looked into the musicontology code and I found, that the classes are
> defined as rdfs:class *and* are typed as owl#class using rdf:type. I
> have to admit that I am not that much into owl, rdf, etc. but as I
> understand this (http://www.w3schools.com/rdf/rdf_schema.asp),
> rdfs:Class is just an abbreviation for rdf:Description and
> rdf:type=...rdf-schema#Class -- if that's correct, using rdfs:Class
> and rdf:type owl#Class would be double typing ...

Indeed... Some legacy triples that should be spring-cleaned out.
Most of classes are indeed part of the following triples:
:Performance a owl:Class.
:Performance a rdfs:Class.

I added the OWL typing to please Protege, which wasn't liking MO at the time :)

However, I am quite surprised that it makes Jena crash (as Protege
uses Jena as a backend). Do you use an OntologyModel? In this case it
shouldn't be too bothered to have both owl:Class and rdfs:Class?
What method do you use to list the classes, so that I can try to take a look?

Cheers, and many thanks for that!

y

Nils Reiter <reiter@cl.uni-heidelberg.de>

unread,
May 16, 2008, 5:27:54 AM5/16/08
to Music Ontology Specification Group
Hi,
Well, Jena didn't really crash. It just behaved ... weird.
It listed only one class (SACD), but over and over again.

Unfortunately, I deleted the not working code as soon as I had a
working version, so I can't tell you what I did exactly. If I remember
correctly, it was something like that.

ontology = ModelFactory.createOntologyModel();
ontology.read("file:///proj/ontopop/data/musicontology.rdfs);
ExtendedIterator iter = ontology.listNamedClasses();
while(iter.hasNext()) {
OntClass ocl = (OntClass) iter.next();
System.err.print(ocl.getLocalName());
}

But it's working fine today (even with double typing) -- I guess I
have to admit that my problem was somewhere else ;-)


Thanks for your comments!
Best,
Nils

Yves Raimond

unread,
May 16, 2008, 5:30:49 AM5/16/08
to music-ontology-sp...@googlegroups.com
>
> ontology = ModelFactory.createOntologyModel();
> ontology.read("file:///proj/ontopop/data/musicontology.rdfs);
> ExtendedIterator iter = ontology.listNamedClasses();
> while(iter.hasNext()) {
> OntClass ocl = (OntClass) iter.next();
> System.err.print(ocl.getLocalName());
> }
>
> But it's working fine today (even with double typing) -- I guess I
> have to admit that my problem was somewhere else ;-)
>

Ok, I ll give it a try anyway, thanks for that!

Cheers!
y

Frederick Giasson

unread,
May 16, 2008, 7:29:31 AM5/16/08
to music-ontology-sp...@googlegroups.com
Hi all,

> Indeed... Some legacy triples that should be spring-cleaned out.
> Most of classes are indeed part of the following triples:
> :Performance a owl:Class.
> :Performance a rdfs:Class.
>
> I added the OWL typing to please Protege, which wasn't liking MO at the time :)
>
> However, I am quite surprised that it makes Jena crash (as Protege
> uses Jena as a backend). Do you use an OntologyModel? In this case it
> shouldn't be too bothered to have both owl:Class and rdfs:Class?
> What method do you use to list the classes, so that I can try to take a look?
>
> Cheers, and many thanks for that!
>

Tell me if I am wrong, but normally it shouldn't be a big deal,


In owl-lite & owl-dl, owl:Class is a subclass of rdfs:Class. In owl-full
owl:Class is equivalent to rdfs:Class. So this mean that in a case or
another, having a class that is typed as both rdfs:Class and owl:Class
shouldn't change anything, except being redundant.

Btw Yves, is there any reason why we have to stick with the rdfs:Class
type? owl:Class should do the job; except if some systems complains :)


Take care,


fred

Yves Raimond

unread,
May 16, 2008, 7:27:22 AM5/16/08
to music-ontology-sp...@googlegroups.com
Hello!

>
> In owl-lite & owl-dl, owl:Class is a subclass of rdfs:Class. In owl-full
> owl:Class is equivalent to rdfs:Class. So this mean that in a case or
> another, having a class that is typed as both rdfs:Class and owl:Class
> shouldn't change anything, except being redundant.
>
> Btw Yves, is there any reason why we have to stick with the rdfs:Class
> type? owl:Class should do the job; except if some systems complains :)
>

Oh yeah, it is totally useless now. We should spring-clean that out
one of these days

Cheers!
y

Reply all
Reply to author
Forward
0 new messages