My long term aim is to develop a suite of ontologies which represent part of the knowledge of control engineering. As far as I know it is recommended, to built domain ontologies (reference ontologies, application ontologies) on top of (i.e. by extension) some upper ontology (also called "foundational ontology"). The Basic Formal Ontology (BFO) [2] seems to be an obvious candidate for this. However, I encounter some unexpected hurdles (issues) when I want to work with it in Owlready2.
(My attempts are documented in [1] in more detail.) [1]: https://nbviewer.jupyter.org/github/cknoll/demo-material/blob/main/semantic_methods/unsorted/bfo-experiments.ipynb [2]: https://basic-formal-ontology.org/ Issue 1: `bfo.base_iri` is 'http://purl.obolibrary.org/obo/bfo.owl#' but `bfo.search(label="entity").first().iri` is 'http://purl.obolibrary.org/obo/BFO_0000001' i.e. the substring 'bfo.owl#' from the base iri is missing. This is the reason why `bfo.BFO_0000001` returns `None` which is quite unintuitive. - - - - Issue 2: The concepts of BFO like "generically dependent continuant" or "object aggregate" are IMHO quite hard to grasp for a ontology-newbie like me. Being obligated to reference them via their `.name` attribute like "BFO_0000031" or "BFO_0000027" makes it even harder. Is there some more convenient way to reference objects from bfo via their labels than something like `bfo.search(label="generically dependent continuant").first()` Ideally some solution with auto-completion (in IPython or Jupyter) would be nice. - - - - Issue 3: If I do the following ``` import owlready2 as owl2 bfo = owl2.get_ontology("http://purl.obolibrary.org/obo/bfo.owl").load() annotation_properties = list(bfo.annotation_properties()) # works -> List[str] print(annotation_properties[2].label) # works -> empty list print(annotation_properties[3].label) # works not -> TypeError: print(annotation_properties[0].label) ``` I get a TypeError as the first annotation seems not to have a label. However, the 4th (index 3) also has no label but does not raise a TypeError. - - - - Questions for each issue: a) Am I on the wrong track? Are my assumptions or my expectation wrong? Did I miss something? b) Is there a problem within the BFO (or the version I am using)? c) Is there a problem within Owlready2? Best, Carsten |
Administrator
|
Hi,
For issue 1, you need to use a Namespace: obo = get_namespace("http://purl.obolibrary.org/obo/") print(obo.BFO_0000001) For issue 2, you should avoid referring to entities by their labels, because the label may change in future versions of BFO. Thus you need to refer them as BFO_0000031, which is not convenient, I agree... In such situation, I frequently put the label in a comment at the end of the Python line. Having autocompletion for that could only be achieve with some pluggins for a code editor, I believe. For issue 3, it appears that BFO includes the definition of RDF default annotations (such as label, comment, etc). Consequently, they are listed in bfo.annotation_properties(). However, these default annotations are managed specially in Owlready, and shared between world. This lead to a bug when annotation were asked outside a with block. I've just fixed this bug in the development version of Owlready on Bitbucket. (alternatively, you may also put your code inside a with bfo:... block to fix the problem). Jiba |
Free forum by Nabble | Edit this page |