Skip to content

Base direction #165

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

Merged
merged 19 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/extract-examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def table_to_dataset(table)
# We might think something was an IRI, but determine that it's not
object = RDF::Literal(object.to_s, language: cell.to_sym)
end
when 'Direction'
case cell
when '-', /^\s*$/
else
object = RDF::Literal(object.to_s, datatype: RDF::URI("https://www.w3.org/i18n##{object.language}_#{cell}"))
# We might think something was an IRI, but determine that it's not
end
end
end
repo << RDF::Statement.new(subject, predicate, object, graph_name: gname)
Expand Down
4 changes: 4 additions & 0 deletions common/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
whose value MUST be a <a>string</a> representing a [[BCP47]] language code or <code>null</code>.</dd>
<dt><dfn data-cite="JSON-LD11#dfn-default-object">default object</dfn></dt><dd>
A <a>default object</a> is a <a>map</a> that has a <code>@default</code> key.</dd>
<dt><dfn data-cite="JSON-LD11#dfn-base-direction" data-lt="default base direction">base direction</dfn></dt><dd>
The <a>base direction</a> is the direction used when a string does not have a direction associated with it directly.
It can be set in the <a>context</a> using the <code>@direction</code> key
whose value MUST be one of the strings `"ltr"`, `"rtl"`, or <code>null</code>.</dd>
<dt><dfn data-cite="JSON-LD11#dfn-embedded-context">embedded context</dfn></dt><dd>
An embedded <a>context</a> is a context which appears
as the <code>@context</code> <a>entry</a> of one of the following:
Expand Down
637 changes: 452 additions & 185 deletions index.html

Large diffs are not rendered by default.

238 changes: 238 additions & 0 deletions tests/compact-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -4089,6 +4089,244 @@ <h2>
</dd>
</dl>
</dd>
<dt id='tdi01'>
Test tdi01 term direction null
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi01</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Uses term with null direction when two terms conflict on direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di01-in.jsonld'>compact/di01-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di01-context.jsonld'>compact/di01-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di01-out.jsonld'>compact/di01-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi02'>
Test tdi02 use alias of @direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi02</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Use alias of @direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di02-in.jsonld'>compact/di02-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di02-context.jsonld'>compact/di02-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di02-out.jsonld'>compact/di02-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi03'>
Test tdi03 term selection with lists and direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi03</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Term selection includes values of @list.</dd>
<dt>input</dt>
<dd>
<a href='compact/di03-in.jsonld'>compact/di03-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di03-context.jsonld'>compact/di03-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di03-out.jsonld'>compact/di03-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi04'>
Test tdi04 simple language map with term direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi04</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Term selection with language maps and @direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di04-in.jsonld'>compact/di04-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di04-context.jsonld'>compact/di04-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di04-out.jsonld'>compact/di04-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi05'>
Test tdi05 simple language mapwith overriding term direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi05</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Term selection with language maps and @direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di05-in.jsonld'>compact/di05-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di05-context.jsonld'>compact/di05-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di05-out.jsonld'>compact/di05-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi06'>
Test tdi06 simple language mapwith overriding null direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi06</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Term selection with language maps and @direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di06-in.jsonld'>compact/di06-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di06-context.jsonld'>compact/di06-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di06-out.jsonld'>compact/di06-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tdi07'>
Test tdi07 simple language map with mismatching term direction
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tdi07</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Term selection with language maps and @direction.</dd>
<dt>input</dt>
<dd>
<a href='compact/di07-in.jsonld'>compact/di07-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/di07-context.jsonld'>compact/di07-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/di07-out.jsonld'>compact/di07-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='te001'>
Test te001 Compaction to list of lists
</dt>
Expand Down
63 changes: 63 additions & 0 deletions tests/compact-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,69 @@
"context": "compact/c027-context.jsonld",
"expect": "compact/c027-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tdi01",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "term direction null",
"purpose": "Uses term with null direction when two terms conflict on direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di01-in.jsonld",
"context": "compact/di01-context.jsonld",
"expect": "compact/di01-out.jsonld"
}, {
"@id": "#tdi02",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "use alias of @direction",
"purpose": "Use alias of @direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di02-in.jsonld",
"context": "compact/di02-context.jsonld",
"expect": "compact/di02-out.jsonld"
}, {
"@id": "#tdi03",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "term selection with lists and direction",
"purpose": "Term selection includes values of @list.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di03-in.jsonld",
"context": "compact/di03-context.jsonld",
"expect": "compact/di03-out.jsonld"
}, {
"@id": "#tdi04",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "simple language map with term direction",
"purpose": "Term selection with language maps and @direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di04-in.jsonld",
"context": "compact/di04-context.jsonld",
"expect": "compact/di04-out.jsonld"
}, {
"@id": "#tdi05",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "simple language mapwith overriding term direction",
"purpose": "Term selection with language maps and @direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di05-in.jsonld",
"context": "compact/di05-context.jsonld",
"expect": "compact/di05-out.jsonld"
}, {
"@id": "#tdi06",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "simple language mapwith overriding null direction",
"purpose": "Term selection with language maps and @direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di06-in.jsonld",
"context": "compact/di06-context.jsonld",
"expect": "compact/di06-out.jsonld"
}, {
"@id": "#tdi07",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "simple language map with mismatching term direction",
"purpose": "Term selection with language maps and @direction.",
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"},
"input": "compact/di07-in.jsonld",
"context": "compact/di07-context.jsonld",
"expect": "compact/di07-out.jsonld"
}, {
"@id": "#te001",
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],
Expand Down
6 changes: 6 additions & 0 deletions tests/compact/di01-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"term5": {"@id": "http://example.com/term", "@direction": null},
"@direction": "ltr"
}
}
6 changes: 6 additions & 0 deletions tests/compact/di01-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"http://example.com/term": [
"v5",
{"@value": "plain literal"}
]
}
7 changes: 7 additions & 0 deletions tests/compact/di01-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": {
"term5": {"@id": "http://example.com/term", "@direction": null},
"@direction": "ltr"
},
"term5": [ "v5", "plain literal" ]
}
3 changes: 3 additions & 0 deletions tests/compact/di02-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"direction": "@direction"}
}
3 changes: 3 additions & 0 deletions tests/compact/di02-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"http://example.org/foo": {"@value": "bar", "@direction": "ltr"}
}
4 changes: 4 additions & 0 deletions tests/compact/di02-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"direction": "@direction"},
"http://example.org/foo": {"@value": "bar", "direction": "ltr"}
}
8 changes: 8 additions & 0 deletions tests/compact/di03-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@context": {
"foo_ltr": {"@id": "http://example.com/foo", "@container": "@list", "@direction": "ltr"},
"foo_rtl": {"@id": "http://example.com/foo", "@container": "@list", "@direction": "rtl"}
},
"foo_ltr": ["en"],
"foo_rtl": ["ar"]
}
6 changes: 6 additions & 0 deletions tests/compact/di03-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[{
"http://example.com/foo": [
{"@list": [{"@value": "en", "@direction": "ltr"}]},
{"@list": [{"@value": "ar", "@direction": "rtl"}]}
]
}]
Loading