This post was updated on .
I am new to ontology modeling, so I am bit stumped as to how to appropriately load an ontology found online.
Wordnet is a dictionary-like ontology over the english language and comes with both an owl file and an Ntriples file linked to here http://wordnet-rdf.princeton.edu/about As far as I can tell, the owl file only contains the high-level class ontology, which means that if I just pass the url http://wordnet-rdf.princeton.edu/ontology I only get the class hierarchy, and not the instances (words and word senses) of the dictionary. But I can see that it correctly populates the classes() generator. I tried loading the Ntriples file into RDFlib and it appears that it also contains the class information of the ontology, but when I load it using Owlready2 the classes() and individuals() generators are empty. Do I need to run a reasoner to infer the class hierarchy after loading the triples? This is a separate problem as the reasoner seems to balk at the 2637453 triples in the file. Alternatively, do I need to use imported_ontologies in some way? Or is it just not recommended working with ontologies of this size in owlready? edit: actually, owlready does not even load the owl file properly, but fails on trying to import https://lemon-model.net/lemon, returning the error OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in https://lemon-model.net/lemon, line 7. But the file appears to be well-formed xml? Can load it into RDFlib using the xml format spec. . |
Administrator
|
Hi,
The size is not a problem -- Owlready 2 now supports 1 billion of RDF triples. The problem is that the NT file includes the data but not the classes. Classes are described in the ontology.rdf file. However, ontology.rdf imports lemon, and lemon is in Turtle, a file format not supported by Owlready. I tried to convert it to RDF with Protege, but I also got errors in Protege... After removing the lemon importation in ontology.rdf, I was able to load ontology.rdf and wordnet.nt. I can then get the classes and their instances. On the contrary, individuals() does not work because class instances are not described as individuals... but you can still loop over the classes and get their instances. These problems are common with linked data that are "pseudo" ontology but not real OWL. I got similar problem with DBpedia, but it is usually possible to workaround the problem or repair the files. Jiba |
So what was the correct way to load both wordnet.nt and the corrected ontology.rdf simultaneously? Just call get_ontology on both?
I assume some logic will be missing due to the removed lemon reference. If I convert the file to NT or rdf/xml, is there then a way to load it as a local file so that ontology.rdf will reference the converted file instead of the online ontology? Basically, how does owlready identify whether an ontology with a web-like IRI has been loaded as a local file? |
Administrator
|
Yes, I used get_ontology() to load both files.
To resolve dependencies, the easiest way is to load the dependencies before, e.g. load lemon (il you manage to turn it to OWL), then ontology.rdf, then wordnet.nt. Alternatively, you can also put all files in a directory, add this directory path to onto_path, and name the files with the last part of their IRI (plus .owl if not already present), for example, http://wordnet-rdf.princeton.edu/ontology shoud named ontology.owl. Jiba |
hi, can you please clarify this answer? I have two files ABC.owl (containing class definitions) and ABC_inst.nt (defining instances of those classes), which I would like to load into the same ontology, called onto.
I tried creating a directory ABC_dir, set onto_path to be this pathname, copied both files into it and then said: onto = get_ontology(.../ABC_dir).load() This gives an error, saying that ABC_dir is a directory. If I try instead: onto = get_ontology(.../ABC_dir/ABC.owl).load() the class file is loaded (according to onto.classes()) but the instances file appears not to be (at least according to onto.instances()). Can you please explain what I'm doing wrong. Many thanks for this great package! arthur |
Administrator
|
Hi,
Each ontology should have its own OWL file : one ontology cannot be splited in two files. You should either load each file in a separate ontology, or merge the two files (converting them in NTriple format can facilitate the merge). Jiba |
Free forum by Nabble | Edit this page |