Comments (4)
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.
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.
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:
- retrieve JSON-LD document,
- transform to RDF dataset using the FromRDF API, or similar,
- query the dataset using an appropriate SPARQL CONSTRUCT query,
- retrieve the resulting RDF graph using a JSON-LD format,
- 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.
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)
- Should tests for `@embed`: `@last` be restricted to JSON-LD 1.0? HOT 4
- Framing and Arrays HOT 4
- Ex. 41 Playground doesn't contain `@omitGraph: false` + playground does not apply `@omitGraph` HOT 3
- Can frames produce id maps? HOT 2
- Possible typos HOT 2
- Use a property several time when framing HOT 1
- validation errors/warnings HOT 1
- Language map with global context HOT 1
- IANA profile should be `frame` not `framed` HOT 5
- how to use the `frame` and `framed` profiles? HOT 12
- Fix invalid WebIDL HOT 1
- Change "Lexicographical Order" (and related) to "Unicode code point order". HOT 1
- Possible bug with `@json` being treated as invalid `type` in frame HOT 24
- How to use specific value inside a frame to filter out credentials those do not contain that value
- Framing on nested graphs
- Add test for `@graph` keyword aliasing
- more JSON-LD framed examples for performance testing
- Type Coercion / Node Conversion HOT 3
- Need tests for: Framing matches on specified value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-ld-framing.