-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base direction #165
Base direction #165
Conversation
I have all the algorithm updates except for to/from RDF (a bit of fromRdf is in). Changes to term selection, in particular, but also value expansion and compaction are fairly major, and really need a thorough review. But, it is based on updates to my implementation, so I believe the core logic is sound. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments on the tests:
Some more tests to check invalid language tags and directions may be valuable (separately, and in combination),
such as https://w3.org/ns/i18n#en-us_abc
, https://w3.org/ns/i18n#a b_rtl
and https://w3.org/ns/i18n#a b_abc
.
Minor typo in several test manifests "datatiype" -> "datatype"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skimmed the parts concerning language maps, as I'm not familiar enough with this part of the algorithm to really appreciate the impact of the change.
In the "Value compaction" algorithm, I find steps 7-8-9 very verbose (and yet still incomplete, see my comments). May be I'll make a counter proposal at some point if I find a simpler way to express them.
But all in all, looks good. Thanks for this work.
index.html
Outdated
<var>active property</var>, return the value associated with the | ||
<li class="changed">Otherwise, if <var>value</var> has both `@language` and `@direction <a>entries</a>, | ||
and the `@language` <a>entry</a> matches either the <a>language mapping</a> of | ||
<var>active property</var> or the <a>default language</a> of <var>active context</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't that be
- it matches the language mapping of the active property OR
- the language mapping of the active property is null and it matches the default language of the active context
?
Same for the the direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was resolved in subsequent changes, can you verify?
@rubensworks Updated your typo. Can you suggest some specific tests? I can see I could see combinations of invalid language tags and invalid base directions; not sure if we are checking language tags against BCP47 in any tests, actually. We'd also need to check when converting from RDF. I could see the following combinations, used in both expansion tests, toRdf tests, and fromRdf tests where decoding both
But, I'm not sure we should be putting any real requirements for implementations to completely validate BCP47 other than some obvious problems like illegal characters ('+', '!', '~', |
Co-Authored-By: Pierre-Antoine Champin <[email protected]>
Yes, it is pretty bad. I think this is a case where we go away from precise algorithm to describing the intentions:
Or, words to that effect. |
I simplified value compaction, but there may be some corner cases, so I need to update my implementation to see if this handles everything, but it should read much better. |
…ult language_) to just use _language mapping_ or _default language_, as there is no encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Lots of changes here. That being said, they seem ok to me (modulo some comments I left). I'm obviously saying this without having implemented.
Also, I'm not a fan of the compound literal approach and would probably like to see DB's implementations only support the i18n type approach if we support anything other than dropping @direction
to start when going to RDF. We don't want the technical debt of the compound literal approach so may not support it unless there's clear uptake there. Not sure if anything additional here needs to be marked at risk.
We should probably add at risk to both of these algorithms here, and in the syntax document, so they don't come back to bite us if there's not sufficient implementation support, or the community otherwise rejects them. Looking at the implementation, the compound literal mechanism leverages off of the list support, but is certainly much more heavyweight. I wouldn't be sad if we settled to just use the i18n-datatype mechanism. |
Co-Authored-By: Dave Longley <[email protected]>
Co-Authored-By: David I. Lehn <[email protected]>
…nd the presense of `@index`.
While I agree with this, I wonder whether, at this point, we should not consider these as non-normative, with a note that future versions of JSON-LD would settle on a normative version (or versions) depending on the community's reaction. I am not sure about it, but I still feel a bit uneasy about this WG suggesting normatively a solution in a space that goes beyond JSON-LD proper. |
On the |
Indeed, it was my goal to make them invalid IRIs :-) (they would definitely be applicable for the toRdf tests)
There is indeed one test that checks the validity of language tags.
👍
We do it for IRIs, so in that sense it also makes sense to do it for BCP47. I don't have a strong opinion on this though, so perhaps this can be left open for a future JSON-LD version. |
For the tests to work, all IRIs need to be parsable as N-Quads, so we can't effectively test truly illegal IRIs there. The issue of whether we should validate language tags should be discussed on a call, as the current text only says that processors MAY warn on invalid language tags. |
As I noted, using invalid IRIs is problematic, as you can't parse an N-Quads document with an invalid IRI.
As it happens, [RDF Concepts[(https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal) does require that language tags be well formed according to BCP47:
The other RDF syntaxes use something like the following to validate language tags:
I could see us changing from a MAY validate language tags to MUST be valid either to
This should probably be done in context processing, expansion, and fromRDF algorithms to be consistent. The RDF Concepts regex is probably the one to use, as we're in that family. I created issue #167 for this. |
I'm going to merge this, as all review comments have been cleared, and the remaining issue of validating language tags has been raised in #167. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just reviewed the "Value compaction" allogrithm (I think this was the most signigicant change since my last review). It looks much better now 👍
<li>Otherwise, if <var>number entries</var> is <code>1</code> and | ||
the <a>type mapping</a> of <var>active property</var> | ||
is set to <code>@vocab</code>, return the result of using the | ||
<li>Otherwise, the <a>type mapping</a> of <var>active property</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<li>Otherwise, the <a>type mapping</a> of <var>active property</var> | |
<li>Otherwise, if the <a>type mapping</a> of <var>active property</var> |
</ol> | ||
</li> | ||
<li>Otherwise, if <var>value</var> has an <code>@type</code> <a>entry</a> whose | ||
value matches the <a>type mapping</a> of <var>active property</var>, | ||
return the value associated with the <code>@value</code> <a>entry</a> | ||
set <var>result</var> to the value associated with the <code>@value</code> <a>entry</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
set <var>result</var> to the value associated with the <code>@value</code> <a>entry</a> | |
return the value associated with the <code>@value</code> <a>entry</a> |
</ol> | ||
</li> | ||
<li>If the value of `@language` in <var>item</var> exactly matches <var>language</var>, | ||
if it is not `null`, or is not present, if it is `null`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be clearer
if it is not `null`, or is not present, if it is `null`, | |
if it is not `null`, or is not present, if <var>language</var> is `null`, |
<li>If the value of `@language` in <var>item</var> exactly matches <var>language</var>, | ||
if it is not `null`, or is not present, if it is `null`, | ||
<span class="changed">and the value of `@direction` in <var>item</var> exactly matches <var>direction</var>, | ||
if it is not `null`, or is not present, if it is `null`</span>: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be clearer
if it is not `null`, or is not present, if it is `null`</span>: | |
if it is not `null`, or is not present, if <var>direction</var> is `null`</span>: |
or <var>value</var> has no `@index` <a>entry</a>, | ||
set <var>result</var> to the value associated with the `@value` <a>entry</a>.</li> | ||
</ol> | ||
return <var>value</var>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a remains of a previous version
return <var>value</var>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now "return result".
For w3c/json-ld-syntax#11.
Preview | Diff