Can I Owlready2 pickable?

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

Can I Owlready2 pickable?

Damiano

Hi Owlready2 users,

Owlready2 helps me handle many OWL at the same time. Very helpful.

But big owl files cause long time when I call load(). I think dumping to a binary file using

pickle module is one of the best ways.

Can I make Owlready2 class pickable (serializable) ?

Thank you in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Can I Owlready2 pickable?

Jiba
Administrator
Hi,

I'm not sure the class can be easily pickled.

However, if you want to solve your loading time problem, the easiest solution is to save the quadstore (which is actually a SQLite3 database) in a local file. Loading a saved quadstore take only a fraction of second, independently of the size of the quadstore.

You can do:

default_world.set_backend(filename = "/path/to/your/file.sqlite3")

to store the quadstore in the given file, and then use default_world.save() to write the file.

More info are available in the doc here:

http://owlready2.readthedocs.io/en/latest/world.html#persistent-world-storing-the-quadstore-in-an-sqlite3-file

The only limit is that you cannot save each ontology in a separate quadstore: you need to put everything in the same file. But yoy can safely put all ontologies in the same quadstore, unless they are really big.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Can I Owlready2 pickable?

Damiano

Dear Jiba,


Ii is much faster! 60 seconds for 4 big ontologies to load to only 3 seconds. Thank you for the advice.


Damiano