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.0b4.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.0b4-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shaclgen-3.0.0b4.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.0b4.tar.gz
Algorithm Hash digest
SHA256 83334a11aff4f87bb225e4eda2d30c6cb5ea12d32765f5ec142b9d141e1e7c78
MD5 e9f3f518d0277a951603622aa1b266ea
BLAKE2b-256 a17da89828f711be84538baf9a629d6131aa5fe24aa4c3269d4cc0911388970b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shaclgen-3.0.0b4-py3-none-any.whl
  • Upload date:
  • Size: 46.6 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.0b4-py3-none-any.whl
Algorithm Hash digest
SHA256 c1c06a21fa23c742f484d78105e67ddcd595b0c3f5a473c385c08da799db82e0
MD5 307bdfbe69cd0ba82149f829667aacb5
BLAKE2b-256 85754730d2eff654147503bde3268c5c8e1eb493f7538ce360c4e4ae7e585b31

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