Code Monkey home page Code Monkey logo

Comments (3)

ashleysommer avatar ashleysommer commented on June 12, 2024

@RichDijk
You're right, it should definitely work by passing in a graph as the shacl_graph. I will look into it.

You might not know the answer, but did it work in previous versions before 0.9.8.post1? There were changes to the way the graph loading routine works in the latest version, which may have introduced this bug. EDIT: Nevermind, see below.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@RichDijk I've done some testing and I cannot reproduce the problem you are seeing.

See this gist: https://gist.github.com/ashleysommer/13b6c765539d7ebff3fd25630470b88c
The two functions work the same, but one passes the datafile and shacl file in as strings and the other as graph objects, and as you can see they both return the same validation result

NOTE I had to change a couple of things in your example for it to work.

  1. Typo in shacl graph g2: sh:minlength should be sh:minLength with capital L
  • Without this fix, the shape validation does not apply the minLength rule, so the example passes where it should fail.
  1. Missing prefixes in the RDF Data text.
  • @prefix hei: <http://hei.org/customer/> .
  • @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
  • Without these, rdflib refuses to parse the snippet into a Graph.

from pyshacl.

RichDijk avatar RichDijk commented on June 12, 2024

The typo in sh:minlength was the issue; no issue in pyshacl! The prefixes where in my data; judged this to be irrelevant. I will supply this nex time.
I am using Jupyter Notebook that created some uncertainty for me; but it works fine apparently.
To close did use the following to create the validation graph where the typo occurred:

from rdflib import URIRef, BNode, Literal, Graph, Namespace
from rdflib.namespace import RDF, RDFS , OWL, XSD
from rdflib.plugins import sparql

HEI = Namespace("http://hei.org/customer/")

g2 = Graph()
g2.bind('sh', SH)
g2.bind('hei', HEI)

HeiAddressShape_Street_shape = BNode()
g2.add((HeiAddressShape_Street_shape, RDFS.comment, Literal("Street constraint")))
g2.add((HeiAddressShape_Street_shape, SH.path, HEI.Ship_to_street))
g2.add((HeiAddressShape_Street_shape, SH.minLength, Literal(30)))
g2.add((HeiAddressShape_Street_shape, SH.datatype, XSD.string ))

g2.add((HEI.HeiAddressShape, RDF.type, SH.NodeShape))
g2.add((HEI.HeiAddressShape, SH.targetClass, HEI.Hei_customer))
g2.add((HEI.HeiAddressShape, SH.property, HeiAddressShape_Street_shape))

from pyshacl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.