/pyrdf-prefix

Easily access common RDF vocabularies and your own custom namespaces, for usage with pyoxigraph

Primary LanguagePython

pyrdf-prefix

This project provides a Prefix utility and many predefined prefixes for many popular RDF vocabularies, like RDFS, SHACL, SKOS and OWL. It returns NamedNodes to be used with pyoxigraph.

Usage

from pyoxigraph import NamedNode
from pyrdf_prefix import Prefix

EX = Prefix('https://example.org/ns#')
assert EX.Sponge == NamedNode('https://example.org/ns#Sponge')
assert EX['Crusty-Crab'] == NamedNode('https://example.org/ns#Crusty-Crab')

It also predefines many well-known prefixes, like rdf, skos, sh:

from pyrdf_prefix import RDF, SKOS, SH
from pyoxigraph import Quad

def describe():
    return Quad(EX.MyRestaurant, RDF.type, SKOS.Concept)