-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(shacl): improve type generation #1300
base: main
Are you sure you want to change the base?
Conversation
Thanks for taking this on! I believe sh:datatype should only be used for literals https://www.w3.org/TR/shacl/#validator-DatatypeConstraintComponent ideally the unit tests would use pyshacl to test that validation works as expected but let's hold off on adding that as a dependency for now. For now we can just check the resulting shacl triples map as extended, and we can do an out of band test to ensure the shacl validates as expected |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1300 +/- ##
==========================================
- Coverage 80.39% 80.36% -0.04%
==========================================
Files 77 77
Lines 8923 9004 +81
Branches 2197 2213 +16
==========================================
+ Hits 7174 7236 +62
- Misses 1332 1345 +13
- Partials 417 423 +6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thanks @cmungall Good point - we should pair datatype with Literals only. I am checking my linkml generated shacl against a control rdfs+shacl file someone else created which only declares sh:IRI and sh:Literal nodeKinds. However my PR is naive. From docs: "The values of sh:nodeKind in a shape are one of the following six instances of the class sh:NodeKind: sh:BlankNode, sh:IRI, sh:Literal sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral and sh:IRIOrLiteral. " Is there a way calculate correct nodeKind from value of |
If the range is a type, it’s a literal
If the range is a class with an identifier, iri
Class with no identifier, blank
Enums:
If all PVs have a meaning, iri
If none have meaning, literal
Otherwise iriorliteral
…On Tue, Feb 21, 2023 at 3:13 PM N ***@***.***> wrote:
Thanks @cmungall <https://github.com/cmungall> Good point - we should
pair datatype with Literals only.
I am checking my linkml generated shacl against a control rdfs+shacl file
someone else created which only declares sh:IRI and sh:Literal nodeKinds.
However my PR is naive.
From docs: "*The values of sh:nodeKind in a shape are one of the
following six instances of the class sh:NodeKind: sh:BlankNode, sh:IRI,
sh:Literal sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral and sh:IRIOrLiteral.*
"
Is there a way calculate correct nodeKind from value of
str(Literal(rt.uri)) ?
—
Reply to this email directly, view it on GitHub
<#1300 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMMOJWXGLQSECS3KXYELDWYVD2PANCNFSM6AAAAAAVCK27CA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
5ed2084
to
91377b9
Compare
rt = sv.get_type(r) | ||
if rt.uri: | ||
prop_pv(SH.datatype, rt.uri) | ||
prop_pv(SH.datatype, Literal(rt.uri)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right - even though the value of sh:datatype is used for validating literals, it is not itself a literal
See:
https://www.w3.org/TR/shacl/#DatatypeConstraintComponent
example:
sh:property [
sh:path ex:age ;
sh:datatype xsd:integer ;
] .
Looks like this still has changes requested. |
This PR improves shaclgen.py by adding nodeKind and datatype for Linkml types (fixes #1299)
TODO: I am not sure if
sh:nodeKind sh:IRI
is correct and maybe should besh:nodeKind sh:Literal
.Example output from this PR: