-
Notifications
You must be signed in to change notification settings - Fork 5
(Python) Invoking rudof from Python
Jose Emilio Labra Gayo edited this page Nov 14, 2024
·
3 revisions
If you prefer, you can run this example Google colab: https://tinyurl.com/rudof-demo
pip install pyrudof
from pyrudof import Rudof, RudofConfig
rudof = Rudof(RudofConfig())
with open('path/to/data.file') as fd_data:
rudof.read_data_str(f_data.read())
with open('path/to/shapes.file') as fd_shapes:
rudof.read_data_str(f_shacl.read())
# assuming data is loaded
results = rudof.run_query_str("""
SELECT * WHERE {
?x ?y ?z .
}
""")
for result in iter(results):
print(result.show())
Sample output:
?x -> <iri>
?y -> <iri>
?z -> <iri>
# assuming data and shape files/strings are loaded
result = rudof.validate_shacl()
print(result.conforms()) # returns boolean
print(result.show()) # returns string of issues separated by newline
Sample output:
False
False
18 errors found
Focus node <iri>, Component: sh:minCount, severity: sh:Violation
Focus node prefix:term, Component: sh:minCount, severity: sh:Violation
- (RDF) Information about a node in RDF file
- (RDF) Merge several RDF data files
- (RDF/SPARQL) Information about a node in Wikidata
- (ShEx) Show info about a schema
- (ShEx) Validate a specific node with a shape
- (SHACL) Show info about a SHACL schema
- (SHACL) Read a SHACL Shapes graph and convert to some format
- (SHACL) Validating RDF data using SHACL
- (SPARQL) Running SPARQL queries
- (Python) Invoking this library from Python
- (SHACL → ShEx) Convert SHACL shapes graph to ShEx schema
- (ShEx → SVG/PNG/...) Convert a ShEx schema to an UML-like visualization in SVG, PNG, ...
- (ShEx → HTML) Convert ShEx schemas to HTML views
- (ShEx → SPARQL) Convert a simple ShEx schema to SPARQL
- (DCTap → ShEx) Convert a CSV file in DCTap to a ShEx schema
- (DCTap → SVG/PNG/...) Convert a CSV file in DCTap to an UML-like visualization in SVG, PNG, ...