Code Monkey home page Code Monkey logo

Comments (4)

gkellogg avatar gkellogg commented on June 16, 2024

Something to consider for a future version. It would be good to collect use cases where this is important.

note that you could achieve much better matching, in even more cases, by doing a SPARQL CONSTRUCT and then framing the resulting graph.

from json-ld-framing.

AtesComp avatar AtesComp commented on June 16, 2024

Thanks for the response and consideration.

I've seen other comments about SPARQL CONSTRUCT statements being used. This presumes the original data is accessible via a SPARQL store. However, my use case has no such origin. The data is ingested from an otherwise non-linked data source--raw JSON--and transformed into a standardized JSON-LD format for an RDF store. I could throw it into a temp store and do all the work there, but then why would anyone need JSON-LD over JSON? JSON-LD does 90% of what I'm attempting, so...

I'm attempting to use the JSON-LD standard as a transformative ingester on raw JSON by adding @context, using a framing @context to transform the data to the expected format, and using the JSON-LD standard algorithms to effect transformation by adding missing type with simple inference on structure and content using regex. The JSON-LD specification is so very close to helping me achieve that goal...frustratingly so. I see in the code base that it is using regex to find the specification's internal structures in the data for framing, but doesn't allow for general regex use. I could easily fork and implement as needed, but would rather have an open discussion on the merits.

The basic issue here is general matching for framing. The specification gives us none ([]), all ({}), or exact (a list of specific strings), but no general bridge between "all" and "exact"...no subset other than a list of specific strings. Via the standard, I would need to list all specific matching strings--an unbearable thought. A regex match would solve this issue.

I find it humorous that the proposed solution would use regex to find a regex string to apply regex to a predicate or value.

from json-ld-framing.

gkellogg avatar gkellogg commented on June 16, 2024

JSON-LD Framing is not intended to be a generic query language and attempts to make it such have been resisted. As JSON-LD is an RDF serialization format, SPARQL does, indeed, provide a way of performing generic query. SPARQL is used for querying data, either contained in a triple store, or as represented in an RDF document (e.g., using the FROM clause in SPARQL).

Depending on the JSON-LD library you're using, there is likely a fuller suite of RDF tools available to you and the workflow would be like the following:

  1. retrieve JSON-LD document,
  2. transform to RDF dataset using the FromRDF API, or similar,
  3. query the dataset using an appropriate SPARQL CONSTRUCT query,
  4. retrieve the resulting RDF graph using a JSON-LD format,
  5. frame that result using JSON-LD Framing.

Note that this can typically be done straight from the SPARQL query by referencing the JSON-LD document directly from the FROM clause. By using an appropriate ACCEPT header, or other library-specific option, you can do this entirely from the SPARQL query. IIRC, dydra has a way to specify a frame to use when returning the results of a query as JSON-LD (cc, @lisp).

There are other methods that have varying degrees of acceptance, see for example, GraphQL-LD, for which @rubensworks may have something to say.

from json-ld-framing.

AtesComp avatar AtesComp commented on June 16, 2024

Agreed. Not a query language. Just a transformation step from JSON to JSON-LD...something I can work with.

from json-ld-framing.

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.