No project description provided
Project description
LODKit
LODKit is a collection of Linked Open Data related Python functionalities.
LODkit (includes|will include)
- a custom
rdflib.Graph
subclass that is capable of- RDFS and OWL-RL inferencing
- Bnode-safe graph merging [todo]
- a custom importer for loading RDF files as if they where Python modules
- [...]
Examples
lodkit.Graph
lodkit.Graph
is an rdflib.Graph
subclass that is cabable of RFDS and OWL-RL inferencing.
The default plugin for inferencing is the owlrl native Python inferencing engine. The deductive closure type used for lodkit.Graph
is RDFS_OWLRL_Semantics which allows for RDFS and OWL-RL reasoning.
from lodkit import Graph
from rdflib import Namespace
ex = Namespace("http://example.org/")
graph = Graph()
graph.add((ex.subj, ex.pred, ex.obj))
graph.add((ex.inverse, OWL.inverseOf, ex.pred))
len(graph) # 2
(ex.obj, ex.inverse, ex.subj) in graph # False
graph.inference(reasoner="owlrl")
len(graph) # 359
(ex.obj, ex.inverse, ex.subj) in graph # True
The reasoner
parameter of lodkit.Graph.inference
(so far) also takes
- "rdfs" for owlrl's RDFS deductive closure type,
- "reasonable" for the reasonable inference engine and
- "allegro" for the Allegrograph reasoner (using the RDFS++ and OWL-RL).
Also the reasoner
parameter takes Reasoner
objects directly, see reasoners.py.
lodkit.importer
lodkit.importer
is a custom importer for importing RDF files as if they where regular Python modules.
RDF files are parsed into rdflib.Graph
instances and made available in the module namespace.
E.g. in a directory structure
├── dir/
│ ├── main.py
│ ├── some_rdf.ttl
│ ├── subdir/
│ └── some_more_rdf.xml
the following creates rdflib.Graph
instances in the current module namespace:
# main.py
import lodkit.importer
import some_rdf
from subdir import some_more_rdf
print(type(some_rdf)) # <class 'rdflib.graph.Graph'>
print(type(some_more_rdf)) # <class 'rdflib.graph.Graph'>
I find this really convenient for bulk-parsing graphs (example).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.