Skip to main content

Shacl graph generator: python program to generate template shacl graphs

Project description

SHACLGEN

Shaclgen takes either an instance graph/data graph (or multiple graphs) or schema(s) as input and generates a basic shape file based on the classes and properties present.

Shape files from instance data: By default, the input graph is processed as a data graph (instance data).

Shape files from ontologies: If the input is a schema or ontology, shaclgen generates a nested shape file: properties with rdfs:domain defined in the ontology will be nested within the appropriate NodeShape. rdfs:range definitions for XML and rdfs datatypes are included.

Added support for OWL constructions is planned.


Installation

Using pip: :

pip install shaclgen

Command line use:

$ shaclgen [graph] [optional arguments]

Example usage: :

$ shaclgen https://www.lib.washington.edu/static/public/cams/data/datasets/uwSemWebParts/webResource-1-0-0.nt

Command line arguments: :

positional arguments:
graph                 The data graph(s).

optional arguments:
-h, --help            show this help message and exit
-o, --ontology        input file(s) or URL(s) is a schema or ontology
-ns, --namespace      optional shape namespace declaration. ex: http://www.example.com exam
-i, --implicit        use implicit class targets with RDFS
-s SERIALIZATION, --serialization SERIALIZATION
                      result graph serialization, default is turtle. example:. -s nt

Serialization options: turtle = turtle ntriples = nt rdfxml = xml n3 = n3

Namespace Example usage: :

$ shaclgen https://www.lib.washington.edu/static/public/cams/data/datasets/uwSemWebParts/webResource-1-0-0.nt -s nt

Namespace argument: The namespace argument is takes a full URL and prefix.

Namespace Example usage: :

$ shaclgen https://www.lib.washington.edu/static/public/cams/data/datasets/uwSemWebParts/webResource-1-0-0.nt -ns http://www.example.org uwlib

Implicit class usage :

SHACL interprets shapes typed as rdfs:Class as the target class of that shape. This is called Implicit Class Targets. By setting -i or --implicit, shaclgen will reuse the class definitions in the ontology (ie. instances of rdfs:Class or owl:Class) as shapes and not create new URIs. Instances of owl:Class will be typed as rdfs:Class in the output. Triples that tie the class to one of its parent classes with rdfs:subclassOf will be copied by default.

Example ontology input:

ex:Person a owl:Class.

Example output without -i:

ex:PersonShape a sh:NodeShape;
    sh:targetClass ex:Person .

Example output with -i:

ex:Person a rdfs:Class; sh:NodeShape.

This project is still in development. Comments, questions, and issues are welcome!

Contact alexiskeelie at gmail.com

Project details


Download files

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

Source Distribution

shaclgen-3.0.0b3.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shaclgen-3.0.0b3-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

Details for the file shaclgen-3.0.0b3.tar.gz.

File metadata

  • Download URL: shaclgen-3.0.0b3.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.8-200.fc43.x86_64

File hashes

Hashes for shaclgen-3.0.0b3.tar.gz
Algorithm Hash digest
SHA256 b1dac7b9bdd6e61c6ab42f5e46c9ee39a67e6980c6d1f31da6787878442ce590
MD5 476dd306d5471a99b92ffdcc82d075de
BLAKE2b-256 46e791a7e9e4fa507d106b2a5a442307465ae4a37f77f773ff85cf4ec3df41b6

See more details on using hashes here.

File details

Details for the file shaclgen-3.0.0b3-py3-none-any.whl.

File metadata

  • Download URL: shaclgen-3.0.0b3-py3-none-any.whl
  • Upload date:
  • Size: 46.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.8-200.fc43.x86_64

File hashes

Hashes for shaclgen-3.0.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 88a67b4ce97a53cab3b05c073413621f3540b0997889280663de1bb9dd35a714
MD5 e302df73ad6296073b3fa3917a0e779f
BLAKE2b-256 6ee94f7506b9e5a43e4c11f64743ca77455bb269ced134936bdcc7df8d47beee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page