Lab: SHACL: Difference between revisions
(Created page with "==Topics== * Validating RDF graphs with SHACL * Running pySHACL ==Useful materials== SHACL: * Section 7.4 ''Expectation in RDF'' in Allemang, Hendler & Gandon's textbook (''S...") |
No edit summary |
||
Line 13: | Line 13: | ||
==Tasks== | ==Tasks== | ||
'''Task:''' Go to the interactive, online [https://shacl.org/playground/ SHACL Playground]. The file [File:xxx.txt] contains a small Turtle | '''Task:''' | ||
Go to the interactive, online [https://shacl.org/playground/ SHACL Playground]. The file [File:xxx.txt] contains a small Turtle example you can paste into the Data Graph text field. The example is based on the ''kg4news.ttl'' graph introduced in the SPARQL lecture (S03). It contains several errors. Take some time to look at it in Turtle and also in JSON-LD, using the drop-down menu next to the ''Data Graph'' heading. | |||
'''Task:''' | |||
Write Shapes Graphs in Turtle (recommended) or JSON-LD for each of the checks below. Keep copies of your of your Shape Graphs in a separate text editor and file. You will need them later. Each time you have entered a Shape Graph into the text field, click ''Update'' to validate the contents of the Data Graph. | |||
* Every kg:MainPaper has (is the subject of) exactly on kg:year property. | |||
* Every kg:year value (literal object) is an integer. | |||
You can use the following prefixes: | |||
xxx | |||
'''Task:''' Install pySHACL into your virtual environment: | '''Task:''' Install pySHACL into your virtual environment: | ||
Line 21: | Line 31: | ||
==If you have more time== | ==If you have more time== | ||
'''Task:''' | |||
Fix ''kg4news.txt'' (renamed to ''.ttl'') so that: | |||
* Every kg:year value has rdf:type xsd:year . |
Revision as of 10:44, 17 February 2023
Topics
- Validating RDF graphs with SHACL
- Running pySHACL
Useful materials
SHACL:
- Section 7.4 Expectation in RDF in Allemang, Hendler & Gandon's textbook (Semantic Web for the Working Ontologist)
- Chapter 5 SHACL in Validating RDF (available online)
- Interactive, online SHACL Playground
pySHACL:
- pySHACL at PyPi.org After installation, go straight to "Python Module Use".
Tasks
Task: Go to the interactive, online SHACL Playground. The file [File:xxx.txt] contains a small Turtle example you can paste into the Data Graph text field. The example is based on the kg4news.ttl graph introduced in the SPARQL lecture (S03). It contains several errors. Take some time to look at it in Turtle and also in JSON-LD, using the drop-down menu next to the Data Graph heading.
Task: Write Shapes Graphs in Turtle (recommended) or JSON-LD for each of the checks below. Keep copies of your of your Shape Graphs in a separate text editor and file. You will need them later. Each time you have entered a Shape Graph into the text field, click Update to validate the contents of the Data Graph.
- Every kg:MainPaper has (is the subject of) exactly on kg:year property.
- Every kg:year value (literal object) is an integer.
You can use the following prefixes:
xxx
Task: Install pySHACL into your virtual environment:
pip install pyshacl
If you have more time
Task: Fix kg4news.txt (renamed to .ttl) so that:
- Every kg:year value has rdf:type xsd:year .