Re: Bodies resource from Benjamin - lists or sets

(In general, I agree with Doug that we should "publish an updated Data Model spec to TR, and then explore this further if the WG feels like it's an interesting and fruitful direction." Ie, this comment is in direction of that further discussion and not for the upcoming TR document!)

Rob,

this is only a comment on the lists and sets. I will send another mail commenting on the overall construction (and thanks for having clarified it!)

> On 02 Sep 2015, at 05:20 , Robert Sanderson <azaroth42@gmail.com> wrote:
> 
> 
> Okay, as this has not been discussed previously, we should give it a fair shot...
> 
> Riffing on the strawperson from Benjamin and the mention of Composites from Jacob, today I have been trying to model the requirements we have in the following way:
> 
> The body or target of an annotation is a Composite, where that resource has relationships to the included resources.  Those relationships would replace the use of motivations, and the base set would be enumerated in the model.  Additional relationships could be created to cover further use cases, such as the copy-edit replacement or the canvas-painting motivation in IIIF.
> 
> This would NOT suffer from the main objection to using subProperties of hasBody/hasTarget, which is that it would be impossible to determine which resources were bodies, which were targets and which neither, as hasBody/hasTarget would point to the Composite.  As the Composite is a construction within the Annotation, there would be no need to have properties other than motivation replacing relationships, thus a pure JSON/javascript client could iterate through all of the properties (excluding id and type) and know that they were bodies (or targets) even if they do not understand the semantics.  For annotations with a known structure, the direct method of accessing the information would work (anno.body.replacement) meeting the performance requirements expressed.
> 
> For example:
> 
> {
>   "@context": [
>    "http://www.w3.org/ns/anno.jsonld",
>    "http://example.org/ns/edit.jsonld"
>   ],
>   "id": "http://example.org/anno1",
>   "type": "Annotation",
>   "target": {
>    "resource": "http://example.com/doc1"  // should really be a SpecificResource with Selector
>   },
>   "body": {
>      "type": "Composite",
>      "tags": [ {"text": "correction"}, {"text": "typo"} ],
>      "comments": {"text": "wow...I should learn to type..."},
>      "replacements": {"text": "itinerary"}
>   }
> }
> 
> Here resource is oa:item (which we could rename), and tags, comments, replacements are all subProperties of it.  Replacements is defined in the second context.
> 
> 
> However, don't get too excited ... this does NOT work with the other multiplicity constructions where the order of the members is important.
> Although in JSON, the value of "tags" is an array, that is actually the following turtle:
> 
> _:body a oa:Composite ;
>   oa:hasTag [ oa:text "correction"], [ oa:text "typo"]
> 

To make it clear to those who are not JSON-LD people: this is the way JSON-LD is specified[1]. Ie, the semantics of JSON array is to produce a set of statements rather than assign an ordering (alas, JSON does not have a difference between a set and an array).

[1] http://www.w3.org/TR/json-ld/#h3_sets-and-lists


> And not an rdf:List:
> 
> _:body a oa:Composite ;
>   oa:hasTag ( [oa:text "correction"] [oa:text "typo"])
> 
> (Apologies to those who do not speak turtle as a native language -- the first is not ordered, the second is)
> 
> Thus, a Choice of comments could NOT be modeled as:
> 
> "body": {
>   "type": "Choice",
>   "comments": ["http://eg.org/comment-en", "http://eg.org/comment-fr" ]
> }
> 
> Because this would require comments / oa:hasComment to be both ordered in some instances and not ordered in others, which is not possible.
> 
> Two separate keys and predicates that reflect the same motivation could be created (commentsList / oa:hasCommentList, comments / oa:hasComment) but that seems pretty terrible, especially as the values for the two would be identical.
> 
> The current proposal does allow for this use case, as the Composite or Choice would simply have SpecificResources with motivations as items/members.
> 
> Unless someone else can see how this could work (in RDF and JSON please), while fulfilling all of the requirements?

What I do not know is which use case is more frequent. Is it the case that, say 80% of the role values are actually sets (ie, the order is irrelevant), or is it 50% or 20%?

If it is 80%, this means that it is o.k. to make the 20% (ie, when ordering counts) a bit more nasty. In which case we can just adopt the JSON-LD idiom:


"tags": { "@list": [ {"text": "correction"}, {"text": "typo"} ] },

ain't pretty, but if it is really for the 20%, we could live with it.

Ivan

> 
> Rob
> 
> 
> 
> On Tue, Sep 1, 2015 at 10:06 AM, Doug Schepers <schepers@w3.org> wrote:
> Hi, Benjamin–
> 
> I realize that you were probably just putting out a strawman for discussion, and that you were probably making a different point, but since you are talking in code, I thought it would be useful to make a specific point about your code.
> 
> Just a high-level response, inline…
> 
> On 9/1/15 11:40 AM, Benjamin Young wrote:
> On Tue, Sep 1, 2015 at 11:21 AM, Robert Sandersonwrote:
> 
> 
>         Where this is trending now in my head is that we *keep*
>         motivation on the annotation, but create classes for bodies.
>         What this *might* look like in JSON-LD is something like:
> 
>         ```
>         {
>            "type": "Annotation"
>            "motivation": "editing",
>            "bodies": {
>              "tags": ["correction", "typo"],
>              "comment": "wow...I should learn to type...",
>              "edit": {
>                "original": "itinirary",
>                "replacement": "itinerary"
>              },
> 
> This should not be necessary, under any of the proposals we'd been considering thus far.
> 
> My immediate reaction was (I think) similar to Rob's:
> 
>     * A pattern for extension that doesn't involve subProperties is what
>     we have now.
> 
> If I'm reading Rob correctly, this means that none of the bodies (or targets) should have special sub-properties (or sub-structures) of the same type (e.g. motives/motivations/roles) that require special parsing or processing.
> 
> (Note that Target does have Selectors each with idiosyncratic properties, but in this case, I think it's unavoidable and they are clearly defined.)
> 
> 
> Without making any judgment for or against other aspects of your strawman, and keeping everything else the same to isolate this single point for discussion, here's how I'd reformulate your strawman:
> 
>  ```
>  {
>     "type": "Annotation"
>     "motivation": "editing",
>     "bodies": {
>       "tags": ["correction", "typo"],
>       "comment": "wow...I should learn to type...",
>       "edit": "itinerary",
>       "related": ["http://dictionary.reference.com/browse/itinerary"]
>     },
>     "target": "http://example.com/doc1"
>     "target": {
>       "source": "http://example.com/doc1",
>       "selector": {
>         "type": "oa:TextQuoteSelector",
>         "exact": "itinirary"
>       }
>     }
>  }
>  ```
> 
> Yes, it's slightly longer. But has the same functionality, and it avoids two crucial problems:
> 
> 1) the needless duplication of information;
> 1a) you'd need a TextQuoteSelector in the target anyway to correctly anchor the selection;
> 1b) mechanisms that duplicate information in multiple places are prone to getting out of sync and causing problems;
> 
> 2) the need for idiosyncratic and potentially unpredictable additional structures or properties within a known type of property
> 2a) this makes processing more difficult even for known structures of this type
> 2b) introducing such a structure into an extension point sets a pattern that makes graceful degradation very difficult
> 
> 
> And, again, it's not necessary. I think it's useful for use to talk about these edge cases (and central use cases) because it helps us validate that our design is practical and versatile. In this case, you wrote some strawman code that might well have been done by a developer unfamiliar with the data model's design principles, and we were easily able to reformulate it into something that easily avoids the problems.
> 
> This tells me 2 things:
> 
> 1) the data model is strong and flexible;
> 
> 2) we need to be really clear about how the model works, in terms the average developer can understand, and show explicitly how to add extensions (where they can be added, and how they should be structured); we can provide examples to make it clearer (like Rob's  “antecedent” and “subsequent” motives).
> 
> 
> 
> 
> On a related topic (which I'm putting here just to capture it)…
> Note that this my formulation has a somewhat interesting side effect. Since the TextQuoteSelector doesn't have a "prefix" or "suffix", it's ambiguous which instance of the "exact" quote value "itinirary" it's referring to, if there was more than one misspelling in the same document. Is it the first instance? The last instance? All instances? Is this a hack for spellcheck, or an abuse of the data model? Should this be expressed as multiple targets? Or should we define some "all instances" property? Or should we require a "prefix" and/or "suffix"? Is the Data Model the right place to define UA behavior for resolving selectors? Or should there be another spec, perhaps something that defines UA behavior for selectors in terms of RangeFinder and other APIs?
> 
> Food for thought.
> 
> Regards–
> –Doug
> 
> 
> 
> 
> --
> Rob Sanderson
> Information Standards Advocate
> Digital Library Systems and Services
> Stanford, CA 94305


----
Ivan Herman, W3C
Digital Publishing Lead
Home: http://www.w3.org/People/Ivan/
mobile: +31-641044153
ORCID ID: http://orcid.org/0000-0003-0782-2704

Received on Wednesday, 2 September 2015 10:29:38 UTC