-
Notifications
You must be signed in to change notification settings - Fork 15
Run SHACL Play App from command line
- Prerequisite : you need Java 11 installed
- Download the file shacl-play-app-X.Y.Z-onejar.jar from the release section
- Open a command line and run
java -jar shacl-play-app-X.Y.Z-onejar.jar
, you should get the full synopsis of all possible commands with their options.
The general synopsis of the command is the following :
java -jar shacl-play-app-X.Y.Z-onejar.jar <command> <options>
To get help on a specific command, run
java -jar shacl-play-app-X.Y.Z-onejar.jar <command> --help
A typical run to validate some input data against a SHACL file and generate both an HTML report and the raw RDF validation report is the following :
java -jar shacl-play-app-X.Y.Z-onejar.jar validate \
--input <path/to/input.rdf> \
--shapes <path/to/shapes.ttl> \
--output validation-report.html \
--output validation-report.ttl
Analyses the content of an input SPARQL endpoint or RDF file to compute statistics based on an input SHACL file. The statistics computed and the number of instances of each class, the number of occurrences of each property shapes, and the number of distinct values for each property shapes.
The input SHACL file can be the one obtained from the generate
command.
analyze Analyzes an input dataset against a provided SHACL file, and
counts the number of instances/occurrences of each NodeShapes /
PropertyShapes in the dataset. Outputs a void:Dataset entity with
partitions holding the count.
Usage: analyze [options]
Options:
-e, --endpoint
URL of SPARQL endpoint to analyze (e.g.
https://dbpedia.org/sparql). Either endpoint or input needs to be
specified.
-i, --input
Input data file to analyse. This can be repeated for multiple
input files, and can point to a directory. Either endpoint or
input needs to be specified.
* -o, --output
Path where the statistics model will be written. The format of the
file is determined based on the file extension : '*.ttl, *.rdf,
*.n3, *.nq, *.nt, *.trig, *.jsonld'
-os, --outputShapes
Path where the shapes graph will be written. The shapes graph will
be enhanced by the statistical analysis process, with sh:in
constraints when a few values have been found i nthe statistics.
This is optional: if not provided, shapes will not be written
back. The format of the file is determined based on the file
extension : '*.ttl, *.rdf, *.n3, *.nq, *.nt, *.trig, *.jsonld'
* -s, --shapes
Path to the shapes file against which the input data should be
analyzed
Example usage:
java -jar shacl-play-app-0.8.0-onejar.jar analyze \
--shapes nakala-shacl-raw.ttl \
--endpoint https://www.nakala.fr/sparql \
--output nakala-statistics.ttl
Generates a documentation page from a SHACL input file, in HTML or PDF, in a given language. Same as https://shacl-play.sparna.fr/play/doc.
doc Generates a documentation page from a SHACL input file, in HTML
or PDF, in a given language.
Usage: doc [options]
Options:
-d, --diagram
Include diagram in the generated documentation.
Default: false
-h, --hide
hide datatype properties.
Default: false
-m, --img
Upload your logo on the document, local or through a link.
* -i, --input
Path to a input Shapes file, or directory containing multiple
files.
* -l, --language
Language code to generate documentation in, e.g. 'en', 'fr', etc.
* -o, --output
Path to an output file, with extension *.html or *.pdf
-w, --owl
Path to a input OWL ontology file, or directory containing
multiple files.
-p, --pdf
print a pdf file.
Default: false
Draw a UML diagram from a SHACL file. Same as https://shacl-play.sparna.fr/play/draw.
draw Draw a UML diagram from a SHACL file
Usage: draw [options]
Options:
* -i, --input
Path to a input Shapes file, or directory containing multiple
files.
* -o, --output
Path to an output file, with extension *.png or *.svg or *.pdf or
*.iuml. Can be repeated to generate multiple outputs.
-s, --sub
Set this option to include subClassOf links in the diagram, from
rdfs:subClassOf assertions. Defaults to false
Default: false
Removes property shapes from an input SHACL file, based on the usage statistics of the property. Properties used on less than 0.1% of the instance of the class are removed from the input SHACL file. This is useful to remove rarely used properties from the SHACL file.
The input SHACL file and the input statistics file can be the ones obtained from the generate
and statistics
commands.
filter Filters a shape model against a statistics file. Properties
used less than 0.1% of the time will be removed from the SHACL
file.
Usage: filter [options]
Options:
-d, --description
Copies statistics on the description of shapes. Defaults to false
Default: false
* -o, --output
Path where the statistics file will be written. The format of the
file is determined based on the file extension : '*.ttl, *.rdf,
*.n3, *.nq, *.nt, *.trig, *.jsonld'
* -s, --shapes
Path to the shapes file against which the input data should be
analyzed
* -st, --statistics
Path to the statistics file containing the void:triples count and
void:distinctObject count for each shapes
Example usage:
java -jar shacl-play-app-0.8.0-onejar.jar filter \
--shapes nakala-shacl-raw.ttl \
--statistics nakala-statistics.ttl \
--output nakala-shacl-filtered.ttl \
--description
Generates a JSON-LD context file from a SHACL specification.
generatecontext Generates a JSON-LD context from a SHACL file.
Usage: generatecontext [options]
Options:
* -i, --input
Path to a input Shapes file, or directory containing multiple
files.
* -o, --output
Path to an output file, with extension *.json
Generates the SHACL profile of an input knowledge graph, provided either as an input file or as a remote SPARQL endpoint.
generate Generates the SHACL profile of an input knowledge graph
Usage: generate [options]
Options:
-e, --endpoint
URL of SPARQL endpoint to analyze (e.g.
https://dbpedia.org/sparql). Either endpoint or input needs to be
specified.
-exc, --exclude
List of classes URI to be excluded from the analysis. If a class
is in this list, it will not be analyzed
-inc, --include
List of classes URI to be included in the analysis. Classes not in
the list will not be analyzed.
-i, --input
Input data file to analyse. This can be repeated for multiple
input files, and can point to a directory. Either endpoint or
input needs to be specified.
-nl, --no-labels
Set this option to avoid generating sh:name and rdfs:label on the
shapes. Defaults to false
Default: false
* -o, --output
Path where the SHACL file will be written. The format of the file
is determined based on the file extension : '*.ttl, *.rdf, *.n3,
*.nq, *.nt, *.trig, *.jsonld'
-p, --prefix
Namespace prefixes to be added to the output shapes, in the form
<key1>:<ns1> <key2>:<ns2> e.g.
skos:http://www.w3.org/2004/02/skos/core#
dct:http://purl.org/dc/terms/
Example usage:
java -jar shacl-play-app-0.8.0-onejar.jar generate \
--endpoint https://www.nakala.fr/sparql \
--output nakala-shacl-raw.ttl \
--prefix edm:http://www.europeana.eu/schemas/edm/ \
--prefix schema:http://schema.org/ \
--prefix owl:http://www.w3.org/2002/07/owl# \
--prefix skos:http://www.w3.org/2004/02/skos/core# \
--prefix dct:http://purl.org/dc/terms/ \
--prefix xsd:http://www.w3.org/2001/XMLSchema# \
--prefix foaf:http://xmlns.com/foaf/0.1/ \
--prefix ore:http://www.openarchives.org/ore/terms/ \
--prefix geo:http://www.opengis.net/ont/geosparql# \
--prefix wgs84:http://www.w3.org/2003/01/geo/wgs84_pos#
Infer data based on the provided SHACL file containing rules, and writes the output in the given output file
infer Infer data based on the provided SHACL file containing rules,
and writes the output in the given output file
Usage: infer [options]
Options:
* -i, --input
Path to a local RDF file
* -o, --output
Path to the output file
* -s, --shapes
Path to an RDF file or directory containing the shapes definitions
to use, this can be repeated to merge multiple SHACL files.
Converts an OWL ontology into a SHACL file, in a specified 'conversion style'
Usage: owl2shacl [options]
Options:
* -i, --input
Path to a local RDF file or directory. This can be repeated to read
multiple input files.
* -o, --output
Path to the output file
-s, --style
Style of conversion. Defaults to 'SIMPLE'
Default: SIMPLE
Possible Values: [CLOSED_FLATTEN, CLOSED_IGNOREDPROPERTIES, SIMPLE]
Generates SPARQL queries for dataset generation based on a SHACL input file
Usage: shacl2sparql [options]
Options:
* -i, --input
Path to the input SHACL file
* -o, --output
Path to the output directory where SPARQL queries will be written
-to, --targetsOverride
Path to an optional SHACL file overriding the targets of the main
SHACL file. If provided, the sh:target predicates of the input
file will be replaced by the sh:target from this file.
Example usage:
java -jar shacl-play-app-0.7.0-onejar.jar shacl2sparql --input myShacl.ttl --output sparqlQueries --targetOverride myShaclForTargetOverride
For an example of a "targets override" parameter, see https://github.com/sparna-git/shacl-play/blob/master/shacl-sparql-query-gen/target-override-example/eli-ep_parliamentary-questions_2019.ttl
Executes a set of SPARQL CONSTRUCT queries in batch against a SPARQL endpoint and outputs output in a single file
Usage: sparqlbatch [options]
Options:
* -e, --endpoint
SPARQL endpoint URL to which the queries will be sent
* -o, --output
Path to the output directory where the result file will be written
-p, --prefixesFile
Path to the input RDF (SHACL) file to read prefixes from. If not
provided, no prefix declarations will be set in the output file
* -q, --queries
Path to the input directory containing SPARQL CONSTRUCT files
Example usage:
java -jar shacl-play-app-0.7.0-onejar.jar sparqlbatch --queries sparqlQueries --output path/to/outputFile.ttl --endpoint http://localhost:7200/repositories/myRepo --prefix myShacl.ttl
Validates some input RDF data against the provided SHACL file, and writes the output in one or more output file. The format of the output file(s) is determined based on its file extension.
Synopsys :
Usage: validate [options]
Options:
-c, --copyInput
Path to the file where the input should be copied to be examined
-cd, --createDetails
Asks the SHACL validator to create details for OrComponent and
AndComponents. Defaults to false.
Default: false
-x, --extra
Extra data to use for validation - but not part of validated data
itself. Typically ontology file with subClassOf predicates
* -i, --input
Path to a local RDF file. This can be repeated to read multiple input
files (e.g. data files + ontology file + vocabulary file)
* -o, --output
Path to an output file. This can be repeated to serialize the report in
multiple output files. The format of the file is determined based on the
file extension : '*.html' for the HTML report, '*-raw.html' for a raw
listing of validation results, '*-summary.html' for a raw rendering of
a summary of validation results, '*.ttl' or '*.rdf' for an RDF
serialisation of the report, in Turtle or RDF/XML, '*.csv' for a CSV
serilisation of the validation results
* -s, --shapes
Path to an RDF file containing the shapes definitions to use
-ns
Namespace prefixes, in the form <key1>,<ns1> <key2>,<ns2> e.g.
skos,http://www.w3.org/2004/02/skos/core# dct,http://purl.org/dc/terms/