Parsing MeSH RDF with Owlready2 returns empty ontology

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

Parsing MeSH RDF with Owlready2 returns empty ontology

rsgoncalves
After loading MeSH (ftp://ftp.nlm.nih.gov/online/mesh/rdf/mesh.nt.gz) with Owlready2 I obtain an ontology object that has no classes, individuals, or properties (i.e., onto.classes(), onto.individuals(), etc., return empty collections). There are no errors or warnings thrown during loading. I'm using Owlready2 v0.31 and Python 3.9.5.

For comparison, when loading MeSH with the OWL API (and Protege), it parses appropriately and I can browse the class hierarchy and obtain MeSH terms.

Any help or hints to fix the issue are much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing MeSH RDF with Owlready2 returns empty ontology

Jiba
Administrator
Hi,

The problem is that the MeSH NT file is plain RDF, and not OWL. Consequently, there is no OWL classes or NamedIndividual in it.

You can still load this file with Owlready, and access to some entities and their properties, e.g.:

>>> x = IRIS["http://id.nlm.nih.gov/mesh/D010163Q000941"]
>>> x.label
['Paleontology/ethics']

However, Owlready cannot list Class since to entity is formally declared as an OWL class.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Parsing MeSH RDF with Owlready2 returns empty ontology

rsgoncalves
Understood—thank you.  Is there a way then to obtain a list of all the IRIs in a loaded ontology?
Reply | Threaded
Open this post in threaded view
|

Re: Parsing MeSH RDF with Owlready2 returns empty ontology

Jiba
Administrator
Hi,

You can get the list of IRI starting with a given prefix as follows:

l = list(default_world.search(iri = "http://id.nlm.nih.gov/mesh/*"))

or with SPARQL:


l = list(default_world.sparql("""SELECT ?x { FILTER(STRSTARTS(STR(?x), "http://id.nlm.nih.gov/mesh/")) }"""))

Jiba