We have an ontology but we need to use the reasoner HermiT to infer the sentiment of a given expression. We have no idea how to use and implement a reasoner in python and we could not find a good explanation on the internet. We found that we can use sync_reasoner() for this, but what does this do exactly? And do we have to call the reasoner manually everytime or does it happen automatically?
You do not need to implement the reasoner. The sync_reasoner()
function already calls HermiT internally and does the reasoning for you.
A reasoner will reclassify individuals and classes for you which means it creates a parent-child hierarchy of classes and individuals. When you load an ontology only explicit parent-child relations are represented. However, when you call the reasoner, the parent-child hierarchy is updated to include inferred relations as well.
An example of this is provided in Owlready2-0.5/doc/intro.rst
. Before calling sync_reasoner()
calling test_pizza.__class__
prints onto.Pizza
, which is explicit information. However, after calling sync_reasoner()
calling test_pizza.__class__
prints onto.NonVegetarianPizza
, which is the inferred information.