Horizontal example: usercase_ontology.owl
I'm trying to reproduce the horizontal example on my computer.
Where do I find the ontology (../vertical/usercase_ontology.owl) referenced in the very first step?
https://github.com/emmo-repo/EMMO-python/blob/b8e2d1017dc795e1788ff9548192e09f50ca5472/demo/horizontal/step1_generate_metadata.py#L29
There is no such file nowhere in the repository. Am I supposed to use ../vertical/demo.owl instead (the result of the vertical example)? Am asking because if I do use it, step1_generate_metadata.py produces the following error.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/owlready2/driver.py in parse(self, f, format, delete_existing_triples, default_base)
153 if not line.endswith("\n"): line = "%s\n" % line
--> 154 s,p,o = splitter.split(line[:-3], 2)
155
ValueError: not enough values to unpack (expected 3, got 2)
The above exception was the direct cause of the following exception:
OwlReadyOntologyParsingError Traceback (most recent call last)
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/ontology.py in _load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, **kwargs)
561 elif resolved_url.startswith(web_protocol):
--> 562 return super().load(
563 only_local=only_local,
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/owlready2/namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, url, **args)
954 try:
--> 955 new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
956 except OwlReadyOntologyParsingError:
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/owlready2/driver.py in parse(self, f, format, delete_existing_triples, default_base)
187 if current_line:
--> 188 raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s, line %s." % (getattr(f, "name", getattr(f, "url", "???")), current_line)) from e
189 else:
OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in https://raw.githubusercontent.com/emmo-repo/EMMO/master/emmo.ttl, line 9.
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/rdflib/plugin.py in get(name, kind)
123 try:
--> 124 p: Plugin[PluginT] = _plugins[(name, kind)]
125 except KeyError:
KeyError: ('text/plain', <class 'rdflib.parser.Parser'>)
During handling of the above exception, another exception occurred:
PluginException Traceback (most recent call last)
/tmp/ipykernel_3270962/3122766218.py in <module>
28 )
29 onto = get_ontology(ontopath)
---> 30 onto.load()
31
32
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/ontology.py in load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, emmo_based, **kwargs)
423 if self.loaded:
424 return self
--> 425 self._load(
426 only_local=only_local,
427 filename=filename,
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/ontology.py in _load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, **kwargs)
569 else:
570 with open(resolved_url, "rb") as handle:
--> 571 return super().load(
572 only_local=only_local,
573 fileobj=handle,
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/owlready2/namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, url, **args)
1004
1005 # Load imported ontologies
-> 1006 imported_ontologies = [self.world.get_ontology(self._unabbreviate(abbrev_iri)).load() for abbrev_iri in self.world._get_obj_triples_sp_o(self.storid, owl_imports)]
1007 self._imported_ontologies._set(imported_ontologies)
1008
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/owlready2/namespace.py in <listcomp>(.0)
1004
1005 # Load imported ontologies
-> 1006 imported_ontologies = [self.world.get_ontology(self._unabbreviate(abbrev_iri)).load() for abbrev_iri in self.world._get_obj_triples_sp_o(self.storid, owl_imports)]
1007 self._imported_ontologies._set(imported_ontologies)
1008
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/ontology.py in load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, emmo_based, **kwargs)
423 if self.loaded:
424 return self
--> 425 self._load(
426 only_local=only_local,
427 filename=filename,
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/ontology.py in _load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, **kwargs)
592 with tempfile.TemporaryDirectory() as handle:
593 output = os.path.join(handle, os.path.basename(resolved_url))
--> 594 convert_imported(
595 input_ontology=resolved_url,
596 output_ontology=output,
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/ontopy/utils.py in convert_imported(input_ontology, output_ontology, input_format, output_format, url_from_catalog, catalog_file)
564
565 graph = Graph()
--> 566 graph.parse(input_ontology, format=fmt)
567 graph.serialize(destination=output_ontology, format=output_format)
568 recur(graph, outext)
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/rdflib/graph.py in parse(self, source, publicID, format, location, file, data, **args)
1253 format = "turtle"
1254 could_not_guess_format = True
-> 1255 parser = plugin.get(format, Parser)()
1256 try:
1257 # TODO FIXME: Parser.parse should have **kwargs argument.
/opt/aixvipmap/2107/conda/envs/emmo/lib/python3.9/site-packages/rdflib/plugin.py in get(name, kind)
124 p: Plugin[PluginT] = _plugins[(name, kind)]
125 except KeyError:
--> 126 raise PluginException("No plugin registered for (%s, %s)" % (name, kind))
127 return p.getClass()
128
PluginException: No plugin registered for (text/plain, <class 'rdflib.parser.Parser'>)
Hi Lukas. Yes, the intention is to run the horizontal demo based on the ontology generated by the vertical demo. When testing it, I am able to reproduce the same errors as you see. These demos were created during in the CSA project which ended in 2019 and clearly need an update.
Hej Jesper (@jesper-friis ) I have same issue with a small - self-generated ontology (just adding some classes into a newly generated ontology, like in the vertical demo) . When I try to import my exported ontology (oso_mesurement-v0.0.1.owl), like:
from ontopy import get_ontology
onto = get_ontology('oso_mesurement-v0.0.1.owl')
onto.load()
I get a similar error (s.below). Shall I open a new issue for that, since it is not directly related to the vertical demo ?
lib/python3.10/site-packages/ontopy/ontology.py:587: UserWarning: Recovering from Owlready2 parsing error... might be deprecated
warnings.warn(
Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?5578c98f-ebe8-42fd-b088-959533a21acc)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/py3venv/lara/lib/python3.10/site-packages/owlready2/driver.py:154, in BaseSubGraph.parse(self, f, format, delete_existing_triples, default_base)
153 if not line.endswith("\n"): line = "%s\n" % line
--> 154 s,p,o = splitter.split(line[:-3], 2)
156 if s.startswith("<"): s = s[1:-1]
ValueError: not enough values to unpack (expected 3, got 2)
The above exception was the direct cause of the following exception:
OwlReadyOntologyParsingError Traceback (most recent call last)
File ~/py3venv/lara/lib/python3.10/site-packages/ontopy/ontology.py:562, in Ontology._load(self, only_local, filename, format, reload, reload_if_newer, url_from_catalog, catalog_file, **kwargs)
561 elif resolved_url.startswith(web_protocol):
--> 562 return super().load(
563 only_local=only_local,
564 reload=reload,
565 reload_if_newer=reload_if_newer,
566 **kwargs,
567 )
569 else:
File ~/py3venv/lara/lib/python3.10/site-packages/owlready2/namespace.py:955, in Ontology.load(self, only_local, fileobj, reload, reload_if_newer, url, **args)
954 try:
--> 955 new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
...
125 except KeyError:
--> 126 raise PluginException("No plugin registered for (%s, %s)" % (name, kind))
127 return p.getClass()
PluginException: No plugin registered for (text/plain, <class 'rdflib.parser.Parser'>)
@markdoerr, you might have to provide a format argument to load(). Since the file extension is .owl, EMMontoPy assumes by default rdf/xml format.
Tak, @jesper-friis , for the hint - the current default format of ontopy.onotogy.load() is set to 'None' . Maybe one should write a few words about the formats in the ontopy documentation ? A few days ago, I installed EMMOntoPy on a new machine and am working now with turtle flies, like you do in your domain-atomistic ontology and everything is magically working (though the interface to ontopy or owlready2 is quite brittle - I have a lot of trouble there). I did not have to specify the format in load(), if I work with turtle/ttl files. @lukas-koschmieder : for a working example, see https://gitlab.com/opensourcelab/scientificdata/ontologies/openscienceontology/measurements