How to work best with the Basic Formal Ontology (BFO) and Owlready2 – 3 issues

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

How to work best with the Basic Formal Ontology (BFO) and Owlready2 – 3 issues

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.)


Issue 1:

`bfo.base_iri` is ''


`"entity").first().iri` is

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

`"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("").load()

annotation_properties = list(bfo.annotation_properties())

# works -> List[str]

# works -> empty list

# works not -> TypeError:


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?

Reply | Threaded
Open this post in threaded view

Re: How to work best with the Basic Formal Ontology (BFO) and Owlready2 – 3 issues


For issue 1, you need to use a Namespace:

obo = get_namespace("")


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).