Skip to main content

No project description provided

Project description

<img src="lodkit.png" width=50% height=50%>

LODKit

License: GPL v3

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lodkit-0.1.1.tar.gz (17.2 kB view hashes)

Uploaded Source

Built Distribution

lodkit-0.1.1-py3-none-any.whl (18.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page