A class for creating a nested dictionaries representation of RDF quads or triples
Project description
A python class for a nested dictionaries representation of RDF quads and triples.
Simple usage:
>>> from rdfdict import RDFdict >>> some_triples = ( ( 's1', 'p1', 'o1' ), ( 's2', 'p2', 'o2' ) ) >>> my_rdfdict = RDFdict(triples=some_triples) >>> my_rdfdict.default_graph() {'s2': {'p2': 'o2'}, 's1': {'p1': 'o1'}} >>> list(my_rdfdict.graphs()) [('DEFAULT', {'s2': {'p2': 'o2'}, 's1': {'p1': 'o1'}})]
RDFdict supports quads or triples. Unless otherwise specified the default graph is called ‘DEFAULT’. When retrieving multiple named graphs they are provided in a list of (name, graph_dictionary ) tuples. When there are multiple objects for a given subject and predicate, the predicate appears once and the objects appear in a list.
Although mainly intended for use with RDF and JSON, RDFdict is actually neutral to either. It does not attempt to manage conversions from RDF to JSON, but if you use RDFlib URIRefs and Literals as the elements in your graphs, they will be correctly converted by json.dumps. See test/test_withrdflib.py for examples.
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.
Source Distribution
File details
Details for the file RDFdict-0.1.6.tar.gz
.
File metadata
- Download URL: RDFdict-0.1.6.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8feb31e6511466c0dd79f24e8bf0087f1883f1644cd433596bcbf66aafe7964b |
|
MD5 | 18403970917aa461abed5fad9c4b985d |
|
BLAKE2b-256 | 6fccd3f40e00e52c77b6994e34e27fdcd9302400b3fd8019fa39865b2d5e4b29 |