Code Monkey home page Code Monkey logo

Comments (8)

gkellogg avatar gkellogg commented on June 20, 2024

I support adding @first. I'll need to work on it, but I think it would be fairly straightforward.

from json-ld-framing.

azaroth42 avatar azaroth42 commented on June 20, 2024

šŸ‘

from json-ld-framing.

azaroth42 avatar azaroth42 commented on June 20, 2024

Was there a WG resolution that we should add this?

from json-ld-framing.

gkellogg avatar gkellogg commented on June 20, 2024

from json-ld-framing.

iherman avatar iherman commented on June 20, 2024

It may be too late to consider this but... I am a little bit bothered by this feature altogether. Looking at, e.g., example 12, and if I understand it right, we are looking at

{
    "@id": "http://example.org/library",
    "@type": "Library",
    "books": "http://example.org/library/the-republic",
    "contains": "http://example.org/library/the-republic"
}

and the value of @first or @last refers to the order of books and contains to choose among them. However, the order of keys within a JSON object does not matter. (There are plenty of references in, e.g., stackoverflow question to various specs stating that.) Nor does the order matter in RDF. So how come we introduce a feature that explicitly refers to the order of keys?

(I may misunderstand something, though...)

from json-ld-framing.

gkellogg avatar gkellogg commented on June 20, 2024

Both @first and @last depend on the algorithm sorting keys, whichi is optional. Thereā€™s an inline editors not about using something like @sample to use the first one found irrespective of order, which would lead to reproducibility issues.

We may simply need to stick with key ordering to make these work.

from json-ld-framing.

iherman avatar iherman commented on June 20, 2024

This issue was discussed in a meeting.

  • No actions or resolutions
View the transcript 4.1. @embed @FIRST issue
Dave Longley: #43
Gregg Kellogg: implemented as well as accompanied by tests
ā€¦ seems straightforward
Dave Longley: or @once (which is a historical name)
Gregg Kellogg: another alternative would be to remove first and last and go back to all or none
Dave Longley: there is an important use case for having at least one of @FIRST or @last
ā€¦ frame docs where you donā€™t care where something appears but it must appear
ā€¦ or certain properties must appear in certain places
ā€¦ historically the name for this was @once
ā€¦ the change was mostly for testing purposes
Ivan Herman: I feel uneasy that we are talking about order in an environment that doesnā€™t inherently have order
Gregg Kellogg: thatā€™s why the algorithms do ordering
Ivan Herman: from the user POV they have to know about the algorithms
ā€¦ which is not ideal. Iā€™m not objecting, just sharing uneasiness
Ivan Herman: can we push this to next week? Itā€™s more than five minutes of talk.
Gregg Kellogg: ivanā€™s comment is not about this specific PR, but about the general point
ā€¦ the existence of @last implies an @FIRST, but the real question is should we be implying ordering at all
Dave Longley: +1

from json-ld-framing.

iherman avatar iherman commented on June 20, 2024

This issue was discussed in a meeting.

  • RESOLVED: Change @last (back) to @once, donā€™t add @first and then figure out testing separately
View the transcript 1.2. @embed @FIRST
Rob Sanderson: link: #43
Gregg Kellogg: We touched on this one. Originally, @embed was true or false, if it was true then one of the uses within a node would contain the embedded value vs. just a reference. That was expanded because it was useful to be able to say ā€œwe want all of themā€ because it would make it much simpler so clients donā€™t have to follow pointers. Also embed @link was added for navigating an internal representation.
ā€¦ We updated it to be the keyword value. And @last was a little arbitrary and the last one expressed in the frame would have the embedded value and @FIRST would be a little more efficient as you donā€™t have to remove other embeds.
ā€¦ First and last implies ordering and all of the ordering is optional and if you donā€™t have order then first and last are non-sensical, so Dave said to use @once but then testing is hard.
ā€¦ This proposal, given that ordering is an option, it makes sense that we also makes sense to be able to say @FIRST vs. @last and itā€™s a separate issue for how these behave or if we need something different if we are not ordering.
Pierre-Antoine Champin: Just an idea on the terminology, @FIRST and @last are misleading ā€¦ perhaps @earliest to @latest or something like that. To make the terms less confusing.
David Newbury: Going through the issue, Iā€™m trying to understand the optionalness of the sorting. It feels like what weā€™re trying to make sure we can do is compare two JS objects as strings.
Gregg Kellogg: That sort of gets into canonicalization ā€“ I believe the tests say we should do a comparison of objects so that ordering isnā€™t important for comparing but also compare the resulting RDF graphs for isomorphism.
ā€¦ But it does make it important to know which of the properties get included in the node or a given subject, in that case, it doesnā€™t change the RDF signature. They all will be references to another object. Itā€™s really in the JSON thing.
ā€¦ Whether you compare unordered or ordered, it still matters where the embedding takes place.
ā€¦ The only way to satisfy these cases is so that you run the algorithm so it does process the properties in order. Otherwise you canā€™t do a structural comparison of the result.
David Newbury: I can say that I have sometimes reordered the properties ā€¦ to match documentation. It shouldnā€™t do that if you use a different keyword. If you do anything to change the order of the JS it doesnā€™t change the meaning of the graph.
Gregg Kellogg: It is sort of a corner case where you have the same thing referred to multiple times.
David Newbury: And it comes up all the time in our data structures. Every time we want to talk about a first name we have an included object that defines first namedness.
ā€¦ We do use repeated signatures throughout the graph.
Rob Sanderson: I can dig up an example. The ordering of the name is arbitrary, the order of the ā€¦ firstnamedness and middlenamedness you donā€™t want to mix that up.
Rob Sanderson: So we do post processing to make sure itā€™s in the right order to look sane.
Ivan Herman: In general, I am really bothered by this. As an author of JSON-LD ā€¦ if I really want to control how the framing worksā€¦ I have to be aware of somewhat arbitrary ordering in the system that is against my way of ordering my properties in my object.
ā€¦ For me, the whole thing is flawed.
Rob Sanderson: My understanding is very similar to David Newberryā€™s ā€¦ if the ordering is important and that will determine where things will be embeddedā€¦
Rob Sanderson: Then the structure will potentially be very very different depending on the names of the keys. It would be very weird to have to put numbers at the beginning of every key to make sure they end up in the right place.
Ivan Herman: I have to do this elsewhere (iTunes) and I hate it.
Rob Sanderson: If the intent is that the structure should be comparable ā€“ then we donā€™t need @FIRST ā€¦ itā€™s just a flag that says ā€œit goes hereā€ such that it will be comparable.
Rob Sanderson: Then I donā€™t think that alphanumeric sorting will help, you donā€™t want @type appearing at the end or in the middle.
Pierre-Antoine Champin: Iā€™m not sure Iā€™m following ivanā€™s arguments
ā€¦ about the expectations of the authors
ā€¦ to me JSON objects are unordered
ā€¦ as annoying as that is, I donā€™t expect the order Iā€™ve written to be preserved
ā€¦ the thing I queued up originally was to ask about @min and @max
ā€¦ to be the smallest or highest key that one can find
ā€¦ that would be reproducible
ā€¦ and avoid key ordering
Dave Longley: so just looking at all this, I would remove all of the ordering
ā€¦ and anything out of any algorithm that would attempt any ordering at all
ā€¦ and highlights that the ordering of constituents back then was incorrect
ā€¦ we mostly did this ordering for the test suites
Ivan Herman: +1 to dlongley
Dave Longley: original name was @once
ā€¦ but what we bumped up again was how do we test this?
ā€¦ because you can get really complicated output
ā€¦ you canā€™t test from the RDF, because that isnā€™t the point of framing
ā€¦ what I recommend we do, is in the test suite
ā€¦ we order the keys in a certain way
ā€¦ letā€™s somehow get the ordering into the test suite
ā€¦ and out of the algorithms
Rob Sanderson: +1 to dlongley - ordering in the test suite, not in the spec
Dave Longley: so that we can still test correct ordering in the test suite
Jeff Mixter: +1 to dlongley
Dave Longley: and removing it out of the algorithm will also speed things up
ā€¦ leaving it where it is will just confuse users anyhow
ā€¦ so removing it is a win for them also
Gregg Kellogg: ordering in the test suite helps
ā€¦ itā€™s been updated to not do order based testing of objects
ā€¦ so I think the issue is about where to do the embedding
Dave Longley: -1 !
Gregg Kellogg: so we should either do no embedding or embed everywhere
ā€¦ anytime you get into having to compare length of strings, youā€™re doing ordering
ā€¦ ordering kills performance
ā€¦ the issue of having @FIRST is predicated on having @last
ā€¦ so what I think weā€™re debating now is should there be any reason to have these at all
ā€¦ so maybe we only normatively require @none and @Always
Gregg Kellogg: https://w3c.github.io/json-ld-api/tests/#json-ld-object-comparison
Gregg Kellogg: there is a section in the test suite README about how we do object comparison
Ivan Herman: I wanted to answer pchampin, but I think weā€™ve moved past that
ā€¦ but +1 to dlongley about removing this
Dave Longley: thereā€™s no way we can just limit this to @none and @Always because there are lots of reasons to just embed one
ā€¦ there are lots of use case where data comes in from somewhere, and you need to pluck out the proof or whatever single thing
ā€¦ and then you need to do some processing on those
ā€¦ and if you inject new triples, that will ruin the data for that processing
ā€¦ so you donā€™t care where the data occurs, just that it does occur
David Newbury: I want to second that
ā€¦ Iā€™d like to create shallow set of look-up types
ā€¦ I donā€™t care where it is
ā€¦ but it would be really obnoxious to have to dedupe it, etc
ā€¦ but where it shows up in the structure is not something Iā€™d ever trust
Gregg Kellogg: then what makes since would be to change @last to @once and then figure out how to test it
ā€¦ so when weā€™re testing we canā€™t do object comparison
ā€¦ and again this sort of goes against the whole purpose of framingā€¦but we would need to flatten the structure to do the comparison
Rob Sanderson: I think weā€™re ready for a proposal
Proposed resolution: Change @last (back) to @once, donā€™t add @FIRST and then figure out testing separately (Rob Sanderson)
Dave Longley: +1
Rob Sanderson: +1
Gregg Kellogg: +1
Ivan Herman: +1
David Newbury: +1
Benjamin Young: +1
David I. Lehn: +1
Tim Cole: +1
Pierre-Antoine Champin: +1
Simon Steyskal: +1
Jeff Mixter: +1
Resolution #2: Change @last (back) to @once, donā€™t add @FIRST and then figure out testing separately
Simon Steyskal: The default for the object embed flag is @FIRST (in addition to the explicit inclusion flag being false), and now?
Dave Longley: default should be @once now because it doesnā€™t add any triples to the graph

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.