-
Notifications
You must be signed in to change notification settings - Fork 17
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
better IO for eye #90
Comments
For the moment you can pipe json-ld translated data into eye as done in https://github.com/eyereasoner/eye/blob/master/reasoning/rdf-star/prepare |
Thanks for that tip, but I don't think that works for Verifiable Credentials which contain quoted graphs. I placed example 6 of the VC data model spec online on my server: > curl -i https://bblfish.net/tmp/2023/08/vcdm.ex6.jsonld
HTTP/1.1 200 OK
Date: Sat, 19 Aug 2023 13:32:55 GMT
Server: Apache/2.4.38 (Debian)
Last-Modified: Sat, 19 Aug 2023 13:23:42 GMT
ETag: "37b-603468dda7e6f"
Accept-Ranges: bytes
Content-Length: 891
Content-Type: application/ld+json
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "http://example.edu/credentials/3732",
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"issuer": "https://example.edu/issuers/565049",
"issuanceDate": "2010-01-01T00:00:00Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts"
}
},
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-02-25T14:58:43Z",
"verificationMethod": "https://example.edu/issuers/565049#key-1",
"proofPurpose": "assertionMethod",
"proofValue": "zeEdUoM7m9cY8ZyTpey83yBKeBcmcvbyrEQzJ19rD2UXArU2U1jPGoEt
rRvGYppdiK37GU4NBeoPakxpWhAvsVSt"
}
} and I received this back > riot --stream=NQuads https://bblfish.net/tmp/2023/08/vcdm.ex6.jsonld
15:34:53 ERROR riot :: [line: 26, col: 76] The document could not be loaded or parsed [code=LOADING_DOCUMENT_FAILED]. even though it gives me correct output for your json-ld urls. |
See the error
|
Ah, thanks. I had fixed that error in the jsonld playground. Btw, following the example > riot https://josd.github.io/temp/vcdm.ex6.jsonld | eye.pvm --quiet --nope -
** ERROR ** - ** invalid_document(after_line(9)) So I guess that is because I uploaded your example and did the minimal work to make it look more like n3, added some prefixes, and that then allowed me to run in through eye: $ eye.pvm --nope https://bblfish.net/tmp/2023/08/vcdm.ex6.ugly.n3 --pass --quiet
@prefix sec: <https://w3id.org/security#>.
@prefix cred: <https://www.w3.org/2018/credentials#>.
@prefix eg: <https://example.org/examples#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix in: <http://n3.w3c.org/builtin/input#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix dc: <http://purl.org/dc/terms/>.
_:e_B077bf894672f5b3c6f076af001ca877e_1 a eg:BachelorDegree.
<http://example.edu/credentials/3732> a cred:VerifiableCredential.
<http://example.edu/credentials/3732> a eg:UniversityDegreeCredential.
_:e_B077bf894672f5b3c6f076af001ca877e_1 <http://schema.org/name> "Bachelor of Science and Arts"^^rdf:HTML.
<did:example:ebfeb1f712ebc6f1c276e12ec21> eg:degree _:e_B077bf894672f5b3c6f076af001ca877e_1.
<http://example.edu/credentials/3732> cred:credentialSubject <did:example:ebfeb1f712ebc6f1c276e12ec21>.
<http://example.edu/credentials/3732> cred:issuanceDate "2010-01-01T00:00:00Z"^^xsd:dateTime.
<http://example.edu/credentials/3732> cred:issuer <https://example.edu/issuers/565049>.
<http://example.edu/credentials/3732> sec:proof {_:e_B6f0d3f77735276663943d536b5ed9c8f_1 a sec:Ed25519Signature2020. _:e_B6f0d3f77735276663943d536b5ed9c8f_1 dc:created "2022-02-25T14:58:43Z"^^xsd:dateTime. _:e_B6f0d3f77735276663943d536b5ed9c8f_1 sec:proofPurpose sec:assertionMethod. _:e_B6f0d3f77735276663943d536b5ed9c8f_1 sec:proofValue "zeEdUoM7m9cY8ZyTpey83yBKeBcmcvbyrEQzJ19rD2UXArU2U1jPGoEtrRvGYppdiK37GU4NBeoPakxpWhAvsVSt"^^sec:multibase. _:e_B6f0d3f77735276663943d536b5ed9c8f_1 sec:verificationMethod <https://example.edu/issuers/565049#key-1>}. That is a bit better. And one of the things that it leads one to is this question I asked on n3 issue 204, namely if the Credentials example shown above is quoting the right triples. It seems that the signature should be on the signed triples that make a statement about |
I don't understand why you are using eye.pvm as a command? Then it should all work fine:
|
Ah I somehow was on eye version 2.5.0. After updating the repo with your latest changes, and installing, and changing the path from @prefix sec: <https://w3id.org/security#>.
@prefix cred: <https://www.w3.org/2018/credentials#>.
@prefix eg: <https://example.org/examples#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix dc: <http://purl.org/dc/terms/>.
@prefix sch: <https://schema.org/>. to the result and run eye on that enhanced file, I get a bit of an improved output, but it still looks very nquadish. I guess at that point I could run it through jen3. But now I have the latest version installed. |
@bblfish wrote:
Ah but that is because it is. Your output is an intermediate format between NQuads and n3. That makes sense if we follow the idea that N3 should be to NQuads what turtle is to NTriples -- but that is why I was thinking N3 should then be called N4! :-) I don't think that has made it into the n3 spec, but I'd be ok to support that, as it would make conversion between NQuads and N4 easier to follow. Is there not a way with |
The native eye reasoner does not have any notion of NQuads, only NTriples, Turtle, N3 and N3S (the latter being N3 for RDF Surfaces). There is also no plan to extend that in the native eye but as you can see in eye-js
All this work is done by @jeswr and I am very happy for that! |
In addition to eye-js another couple of pointers for JS land are:
|
What format is the output of the command @josd ran in the comment above? It contains triples, quads, but also shortcuts that are not part of the NQuads standard such as _:e_B25b8566811e3bf22ddd8f246ee444ea0_1 a <https://example.org/examples#BachelorDegree>.
<http://example.edu/credentials/3732> a <https://www.w3.org/2018/credentials#VerifiableCredential>.
<http://example.edu/credentials/3732> a <https://example.org/examples#UniversityDegreeCredential>.
_:e_B25b8566811e3bf22ddd8f246ee444ea0_1 <http://schema.org/name> "Bachelor of Science and Arts"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>.
<did:example:ebfeb1f712ebc6f1c276e12ec21> <https://example.org/examples#degree> _:e_B25b8566811e3bf22ddd8f246ee444ea0_1.
<http://example.edu/credentials/3732> <https://w3id.org/security#proof> _:e_B0671f6832a73a9929693b26bef4630f9_1.
<http://example.edu/credentials/3732> <https://www.w3.org/2018/credentials#credentialSubject> <did:example:ebfeb1f712ebc6f1c276e12ec21>.
<http://example.edu/credentials/3732> <https://www.w3.org/2018/credentials#issuanceDate> "2010-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
<http://example.edu/credentials/3732> <https://www.w3.org/2018/credentials#issuer> <https://example.edu/issuers/565049>.
_:e_B9e3bfecb2a361ee1e6d6889af3180e07_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/security#Ed25519Signature2020> _:e_B0671f6832a73a9929693b26bef4630f9_1.
_:e_B9e3bfecb2a361ee1e6d6889af3180e07_1 <http://purl.org/dc/terms/created> "2022-02-25T14:58:43Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:e_B0671f6832a73a9929693b26bef4630f9_1.
_:e_B9e3bfecb2a361ee1e6d6889af3180e07_1 <https://w3id.org/security#proofPurpose> <https://w3id.org/security#assertionMethod> _:e_B0671f6832a73a9929693b26bef4630f9_1.
_:e_B9e3bfecb2a361ee1e6d6889af3180e07_1 <https://w3id.org/security#proofValue> "zeEdUoM7m9cY8ZyTpey83yBKeBcmcvbyrEQzJ19rD2UXArU2U1jPGoEtrRvGYppdiK37GU4NBeoPakxpWhAvsVSt"^^<https://w3id.org/security#multibase> _:e_B0671f6832a73a9929693b26bef4630f9_1.
_:e_B9e3bfecb2a361ee1e6d6889af3180e07_1 <https://w3id.org/security#verificationMethod> <https://example.edu/issuers/565049#key-1> _:e_B0671f6832a73a9929693b26bef4630f9_1. |
It is an experimental thing to see if we could deal with n-quads
|
That's what I thought and why I suggested it could be called N4 above. |
For the moment, it is a lot of work to get via the Jena and eye from JSON-LD to nice looking n3. Perhaps with the help of the JS N3 tools mentioned above the JsonLD playground could just get us there in one step! I guess @msporny would know who would be interested in that... |
Yes, we have tried to fix this in the specification by inserting a non-whitespace-break in the examples. Let us know if you find any other examples that are malformed when copied out of the spec.
The JSON-LD Playground is open source, so anyone can add features to it: https://github.com/json-ld/json-ld.org/tree/main/playground ... though, I'm confused about what the ask is here. /cc @davidlehn |
@msporny wrote:
I think it would be nice if one could put JsonLD into the playground and get beautiful N3 out as specified by the N3 CG Notation3 spec. The reason is that the N3 output can be very readable. Currently, the playground only has an NQuads output which is good for machine readability but not for human consumption. |
Ah, yes, that would be fairly easy to do if there was a JS library that can convert NQuads to N3 (or similar). We don't have the bandwidth right now to add that feature, but as I said, the playground is open source so just about anyone can raise a PR to add the functionality. |
Yup - the pretty-turtle library does pretty n3 as well so it should be good for your purposes :) |
Right and it is straightforward to have an N3 rule to collect the quads in graph terms e.g.
will give you
|
If you want to avoid that
|
One reason I used CWM was just to avoid having to read rdf/xml when it was the fashion. Now it would help me to quickly read JSON-LD which is very helpful to get JSON folk to use rdf data, and to make extensible json schemas, but actually very difficult to read.
Currently, I take some json-ld, go to the json-ld playground, transform the json-ld to Nquads, then by hand I group statements with the same bnode
_:bx
by enclosing them in a_:bx <https://example.org/ns/semantics#quotedGraph> {... }
.Then it would be lovely if eye could produce some nice readable n3 output (perhaps I could give it some namespaces? But I could not find out how to do that.
So the following would be really nice:
If anyone else has n3 JavaScript parsers from json-ld to n3 those should be added to the json-ld playground -- please!
I got this working using Jen3, with a bit of pain. For details see Jen3 issue1
The text was updated successfully, but these errors were encountered: