Loading ontology in Python

I have an ontology written in OWL. Does anyone know that I can load it in python? any packages or even manually? rdflib, which is mentioned in other issues, does not suit me, because it mainly concerns RDF, and “Seth”, which is a very good library, does not work, because it requires the “Pellet” library, for which the website, it looks like (seth) also works only with JVM 1.4!

+4
source share
4 answers

I have not completely tried this, but you can see how to upload your ontology to sesame seeds and then request it using the Python shell. I played with RDFAlchemy and pySesame a bit, but I still don’t feel how good they are. RDF / OWL databases feel very immature for me as a whole, so expect to encounter some significant technical glitches.

+2
source

In rdfAlchemy in the commands.py file there is a section of commands that was launched for this very purpose. You didn’t use it at that time, but this is exactly what you asked about how to create skyth python from an ontology.

In fact, he uses pasteurized "commands." If you go to the rdfalchemy subdirectory and type:

paster rdfSubject -h

you must see:

 Usage: /home/phil/venv/some_path/bin/paster rdfSubject [options] paster rdfalchemy.commands Create an rdfSubject subclass with descriptors from an RDF Schema will set the rdf_type Descriptors will be created 1. rdfs:domain and rdfs:range are respected 2. rdfSingle is used for properties that are * owl:InverseFunctionalProperty * owl:FunctionalProperty 3. rdfList or rdfContainer is used if the proper range is set 4. rdfMultiple is used for all others The resulting .py file is ment to be a skeleton for the developers confvience. Do not expect to be able to use the raw results. Create an rdfSubject subclass with descriptors from an RDF Schema Options: -h, --help show this help message and exit -v, --verbose -n, --simulate -s SCHEMA, --schema=SCHEMA file name or url of rdfSchema for this class -o FOUT, --fout=FOUT output file name default: stdout (eg ../MyRdfModel.py) -l, --list list valid instances of `owl:Class` in the schema file 
+2
source

To the right, RDFLib works in RDF semantics, so you'll need tools to manage OWL semantics.

What I usually do is to first use another tool to get all triples ( OWLAPI or OWLRL , for example) and then load it into RDFLib.

+1
source

I could also find this ordf , but it seems like they just wrote some text for them. It's not clear how to use it, it's a pity!

0
source

Source: https://habr.com/ru/post/1340996/


All Articles