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

Uploaded Python 3

File details

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

File metadata

  • Download URL: shaclgen-3.0.0b2.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.0b2.tar.gz
Algorithm Hash digest
SHA256 686c72ecc37594a007c692efee5c8edb73fec347f214e4bfbc4d4b99204165e2
MD5 6f10e69d9dea908298166a45244ecf92
BLAKE2b-256 47d4d57b1371d5e33dab151efee82155f32c218fbf8bcc18206246f6638c2315

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shaclgen-3.0.0b2-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.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 453de2f481a11a5087c94559b9041406d1177eb3d26517acd337b8847fee4d32
MD5 763751d4b29509780e18430e23d48fb6
BLAKE2b-256 fbce2ca4550231a6232fb377b7ff0c09ce38102bf31ccc984bb8b6743435747c

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