Skip to main content

RDFGraphGen: A Synthetic RDF Graph Generator based on SHACL Shapes

This is a Python package which can be used to generate synthetic RDF knowledge graphs, based on SHACL shapes.

The Shapes Constraint Language (SHACL) is a W3C standard which specifies ways to validate data in RDF graphs, by defining constraining shapes. However, even though the main purpose of SHACL is validation of existing RDF data, in order to solve the problem with the lack of available RDF datasets in multiple RDF-based application development processes, we envisioned and implemented a reverse role for SHACL: we use SHACL shape definitions as a starting point to generate synthetic data for an RDF graph.

The generation process involves extracting the constraints from the SHACL shapes, converting the specified constraints into rules, and then generating artificial data for a predefined number of RDF entities, based on these rules. The purpose of RDFGraphGen is the generation of small, medium or large RDF knowledge graphs for the purpose of benchmarking, testing, quality control, training and other similar purposes for applications from the RDF, Linked Data and Semantic Web domain.

Usage

The following function can be used to generate RDF data:

generate_rdf(input-shape.ttl, output-graph.ttl, scale-factor)

  • input-shape.ttl is a Turtle file that contains SHACL shapes
  • output-graph.ttl is a Turtle file that will store the generated RDF entities
  • scale-factor determines the size of the generated RDF graph

Installation

RDFGraphGen is available on PyPi: https://pypi.org/project/rdf-graph-gen/

To install it, use:

pip install rdf-graph-gen

After installation, this package can be used as a command line tool:

rdfgen input-shape.ttl output-graph.ttl scale-factor

There are also some optional parameters. You can find out more by using the:

rdfgen --help

Examples

Examples of SHACL shapes based on Schema.org and other types, along with generated synthetic RDF graphs based on these shapes, can be found in the generated examples directory in this repo.

Publications

Remarks

  • A SHACL shape has to have a 'a sh:NodeShape' property and object in order to be recognized as a Node Shape.
  • sh:severity is ignored because it has no useful info.
  • Only predicate paths are supported at this time.
  • Most common sh:datatype scenarios are supported.
  • Currently sh:nodeKind is ignored.

Metadata

Release files for rdf-graph-gen 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rdf-graph-gen 1.2.0
File Size Uploaded
rdf_graph_gen-1.2.0.tar.gz 731.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rdf-graph-gen 1.2.0
File Interpreter ABI Platform
rdf_graph_gen-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.5 MB

Release files / rdf_graph_gen-1.2.0.tar.gz

Download URL rdf_graph_gen-1.2.0.tar.gz
Size 731.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d8fb4957e36770fa2bd6a7b39a71936dadb8febbc9515b4eb0852cf40df7ce80
BLAKE2b-256 checksum
How to use checksums
7e4152934339985ea24c15ebc0ded587f003e784ade84ef39503a2d81fd6c593
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release files / rdf_graph_gen-1.2.0-py3-none-any.whl

Download URL rdf_graph_gen-1.2.0-py3-none-any.whl
Size 735.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa7b526f7282e8a78a874d3a516e2b5bf53e74d2005ad5c6f8ee91c2da12e5fc
BLAKE2b-256 checksum
How to use checksums
d3ab3dcdc6093f72204936f0e54aaa377c8df9309254b3d08a17ec8136514055
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page