Why Another Library?:

I've been working with RDF/OWL data over the past few months. I've been moving away from high-performance databases and NoSQL and towards the semantic web. The semantic web allows us to represent rich, complex relationships between data--in ways we just aren't able to with current database technology. I've found RDF/OWL better suited for representing knowledge of the data I've been working with most recently.

Libraries That Already Exist:

We can query semantic web files with SPARQL. A Python library used to interface with SPARQL already exists. In fact, there is also a library that exists to help process RDF/OWL files in Python. However, I couldn't find anything well-suited to take a python object and transform that into RDF/OWL. So I wrote OWLify.

Explain OWLify:

In order to quickly turn my data into a RDF/OWL file, I wrote a bare minimal library I called OWLify. I only included the functions I needed at the time. I'm putting it up on github for folks to fork and extend as needed. The interface is pretty simple. Creating new RDF-compliant functions should be very straightforward.

Example Code:

from OWLify import OWL

names = ['Janet', 'Marcy', 'Ed']
gender = ['Female', 'Female', 'Male']
colors = ['Red','Blue','Green']

out = OWL('http://www.nikhilgopal.com', 'owl_example.owl', 'http://www.nikhilgopal.com/properties')
for n in range(len(names)):
    out.assertEquivalentTriple(names[n], 'hasColor', colors[n])
    out.assertSubClassTriple(names[n], 'hasGender', gender[n])

Get the Code