Skip to main content

Manipulate OTTR Reasonable Ontology Templates in Python

Project description


Manipulate OTTR Reasonable Ontology Templates in Python.

Package documentation

OTTR documentation

Supported features:

In development:


Manual installation

git clone
cd pyOTTR/
python install

Getting started

The main class to manipulate is OttrGenerator, which is used to load OTTR templates and expand template instances. So, in practice, you only need to create a new generator, load some templates and then execute your instances to produce RDF triples.

By default, all templates from the OTTR template library are loaded when the generator is created.

from ottr import OttrGenerator
# An OttrGenerator is used to load templates and expand instances
generator = OttrGenerator()

# Load a simple OTTR template definition
  @prefix ex: <>.

  ex:FirstName [ottr:IRI ?uri, ?firstName] :: {
    ottr:Triple (?uri, foaf:firstName, ?firstName )
  } .

  ex:Person[ ?firstName ] :: {
    ottr:Triple (_:person, rdf:type, foaf:Person ),
    ex:FirstName (_:person, ?firstName)
  } .

# Parse and prepare an instance for execution
instances = generator.instanciate("""
  @prefix ex: <>.


# Execute the instance, which yield RDF triples
# The following prints (_:person0, rdf:type, foaf:Person) and (_:person0, foaf:firstName, "Ann")
for s, p, o in instances.execute(as_nt=True):
  print("# ----- RDF triple ----- #")
  print((s, p, o)

Project details

Download files

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

Files for ottr, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size ottr-0.0.1.tar.gz (11.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page