How to use an external reasoner

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

How to use an external reasoner

Hamico
Hi Jiba,
Is it possible to use an external reasoner having its jar file? If yes, how is it possible?

Many thanks.
Best regards,
Hamico
Reply | Threaded
Open this post in threaded view
|

Re: How to use an external reasoner

Jiba
Administrator
Hi,

If you want to use an external reasoner, you need to save the ontology in a temporary file, to run the reasoner as a command line app, to capture the reasoner's result on standard output and to parse the result. Both HermiT and Pellet supports are implemented in that way.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How to use an external reasoner

Hamico
Hi Jiba,
Is it possible to have examples of code, both python and command line? I want to use another reasoner, no pellet no hermit. How can I save the ontology in a temporary file?

Many thanks.
Best regards,
Hamico
Reply | Threaded
Open this post in threaded view
|

Re: How to use an external reasoner

Jiba
Administrator
Hi,

You can look at reasoning.py in Owlready2 sources for examples.

Basically, for saving the ontology, use:

    ontology.save("temp_filename", format="ntriples", commit=False)  

NTriples format is faster to serialize, so I use it for temporary file. commit=False avoid commiting the ontology and saving the quadstore if it is stored on disk.

Then, use the subprocess Python standard module for calling the command line (see its doc in Python docs).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How to use an external reasoner

Hamico
Hi Jiba,
I try to use it.

Many thanks.
Best regards,
Hamico