Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edmondchuc/shaclc
A Python SHACL Compact Syntax parser and serializer.
https://github.com/edmondchuc/shaclc
rdf shacl
Last synced: about 2 months ago
JSON representation
A Python SHACL Compact Syntax parser and serializer.
- Host: GitHub
- URL: https://github.com/edmondchuc/shaclc
- Owner: edmondchuc
- License: mit
- Created: 2023-12-28T05:32:31.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-12T16:26:35.000Z (11 months ago)
- Last Synced: 2024-10-14T14:34:37.343Z (2 months ago)
- Topics: rdf, shacl
- Language: JavaScript
- Homepage: https://edmondchuc.github.io/shaclc/
- Size: 133 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python SHACL Compact Syntax Parser
A Python SHACL Compact Syntax parser and serializer based on the specification at https://w3c.github.io/shacl/shacl-compact-syntax/.
All tests defined in [github.com/w3c/data-shapes/shacl-compact-syntax/tests](https://github.com/w3c/data-shapes/tree/gh-pages/shacl-compact-syntax/tests) are passing.
## Browser playground
Play around with the implementation in your browser at https://edmondchuc.github.io/shaclc/.
## Quickstart
Installation.
```shell
pip install shaclc
```Usage.
```python
from shaclc import shaclc_to_graphshaclc_str = """
BASEIMPORTS
PREFIX ex:
shape ex:PersonShape -> ex:Person {
ex:ssn xsd:string [0..1] pattern="^\\d{3}-\\d{2}-\\d{4}$" .
}
"""graph = shaclc_to_graph(shaclc_str)
graph.print(format="longturtle")
```Output.
```
BASE
PREFIX ex:
PREFIX owl:
PREFIX sh:
PREFIX xsd:<>
a owl:Ontology ;
owl:imports ;
.<#PersonShape>
a sh:NodeShape ;
sh:property
[
sh:datatype xsd:string ;
sh:maxCount 1 ;
sh:path <#ssn> ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
] ;
sh:targetClass <#Person> ;
.
```