ruby-rdf / json-ld

Ruby JSON-LD reader/writer for RDF.rb
The Unlicense
231 stars 27 forks source link

Framing JSON-LD Star #58

Open saumier opened 1 year ago

saumier commented 1 year ago

When using Annotation Objects in a JSON-LD-star document, and then using JSON-LD Framing, I am losing the @annotate node.

Does JSON::LD::API.frame need to have the setting rdfstar: true ?

 input =  JSON.parse %({
      "@context": {
        "@base":"http://www.artsdata.ca/resource/",
        "@vocab":"http://www.artsdata.ca/resource/"
      },
      "@graph": [
        {
          "@id": "TheShow",
          "@type": "Performance",
          "performer": {
            "@id": "John",
            "@annotation": {
                "certainty": 1
            }
          }
        },
        {
          "@id": "John",
          "@type": "Person",
          "name" : "John Smith"
        }
      ]
    })

frame = JSON.parse %({
      "@context": {
        "@vocab": "http://ontology.artsdata.ca/"
       },
       "@type": "Performance"
    })

JSON::LD::API.frame(input, frame)

The above example results in the loss of the @annotate node as shown below:

{
  "@context"=>{
     "@base"=>"http://www.artsdata.ca/resource/", 
     "@vocab"=>"http://www.artsdata.ca/resource/"
  }, 
  "@id"=>"TheShow", 
  "@type"=>"Performance", 
  "performer"=>{"@id"=>"John", "@type"=>"Person", "name"=>"John Smith"}
}
gkellogg commented 1 year ago

That’s likely the issue, (needing to use the rdfstar option) as annotation is experimental and very well may change radically depending on how the RDF-star group progresses. You might also be running into implementation corner cases which I may be able to address.

saumier commented 1 year ago

I tried using JSON::LD::API.frame(input, frame, { rdfstar: true }) to no avail.

gkellogg commented 1 year ago

I’ll look into it soonish.

saumier commented 1 year ago

Thanks in advance. That would be a big help. I hope to contribute back one day :-)

saumier commented 1 year ago

Hi. I apologize for disturbing you. I am having a meeting this week on the delivery of project related to the Swiss Archives of Performing Arts. I was wondering if I could say to them that you are looking into this issue, or rather say there is a known issue and a workaround must be found. Thx for your feedback.

gkellogg commented 1 year ago

Sorry, on vacation this week, and I am backed up with other things on a timeline. I will look into it, but it may be another week or two before I can figure it out and release an update.

I’ll update sooner if I can localize the issue that suggests a fix. I don’t expect it to be difficult, and it may also impact the algorithm from the spec.

gkellogg commented 1 year ago

I've looked at the code, and IIRC, the @annotation implementation for flattening and framing is fairly unexplored, and will require some more investigation. Your use case should be supported but it is missing tests and may take some time to explore.

Note, as said above, that RDF-star is pretty exerimental, and the semantics are still being worked out, and the annotation property may change or even go away, depending on how standards efforts develop. I'd caution you against depending on it for any product use before standards work progresses in RDF-star, and JSON-LD-star is updated to consider this change, and subsequently this implementation.

That said, the use of @annotation is intended to work in this gem, and missing functionality should be implemented, but it will be more than a simple fix, I'm afraid.

saumier commented 1 year ago

Thanks for your valuable insights. I’ll follow the development closely.