rdf-tabular 0.4.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +24 -5
  3. data/VERSION +1 -1
  4. data/etc/csvw.jsonld +135 -50
  5. data/lib/rdf/tabular/csvw.rb +215 -181
  6. data/lib/rdf/tabular/format.rb +8 -6
  7. data/lib/rdf/tabular/literal.rb +1 -1
  8. data/lib/rdf/tabular/metadata.rb +61 -80
  9. data/lib/rdf/tabular/reader.rb +18 -15
  10. data/lib/rdf/tabular/uax35.rb +143 -38
  11. data/spec/data/countries-minimal.json +38 -0
  12. data/spec/data/countries-minimal.ttl +36 -0
  13. data/spec/data/countries-standard.json +86 -0
  14. data/spec/data/countries-standard.ttl +75 -0
  15. data/spec/data/countries.csv +4 -0
  16. data/spec/data/countries.csv-minimal.json +16 -0
  17. data/spec/data/countries.csv-minimal.ttl +19 -0
  18. data/spec/data/countries.csv-standard.json +33 -0
  19. data/spec/data/countries.csv-standard.ttl +44 -0
  20. data/spec/data/countries.html +88 -0
  21. data/spec/data/countries.json +53 -0
  22. data/spec/data/countries_embed-minimal.json +38 -0
  23. data/spec/data/countries_embed-minimal.ttl +36 -0
  24. data/spec/data/countries_embed-standard.json +86 -0
  25. data/spec/data/countries_embed-standard.ttl +75 -0
  26. data/spec/data/countries_embed.html +88 -0
  27. data/spec/data/countries_html-minimal.json +38 -0
  28. data/spec/data/countries_html-minimal.ttl +36 -0
  29. data/spec/data/countries_html-standard.json +86 -0
  30. data/spec/data/countries_html-standard.ttl +75 -0
  31. data/spec/data/country-codes-and-names-minimal.json +19 -0
  32. data/spec/data/country-codes-and-names-minimal.ttl +22 -0
  33. data/spec/data/country-codes-and-names-standard.json +47 -0
  34. data/spec/data/country-codes-and-names-standard.ttl +45 -0
  35. data/spec/data/country-codes-and-names.csv +5 -0
  36. data/spec/data/country_slice.csv +4 -0
  37. data/spec/data/junior-roles.csv +3 -0
  38. data/spec/data/junior-roles.json +54 -0
  39. data/spec/data/roles-minimal.json +32 -0
  40. data/spec/data/roles-minimal.ttl +36 -0
  41. data/spec/data/roles-standard.json +56 -0
  42. data/spec/data/roles-standard.ttl +66 -0
  43. data/spec/data/roles.json +23 -0
  44. data/spec/data/senior-roles.csv +3 -0
  45. data/spec/data/senior-roles.json +52 -0
  46. data/spec/data/test232-metadata.json +10 -0
  47. data/spec/data/test232.csv +3 -0
  48. data/spec/data/tree-ops-atd.json +1 -0
  49. data/spec/data/tree-ops-ext-minimal.json +42 -0
  50. data/spec/data/tree-ops-ext-minimal.ttl +34 -0
  51. data/spec/data/tree-ops-ext-standard.json +93 -0
  52. data/spec/data/tree-ops-ext-standard.ttl +82 -0
  53. data/spec/data/tree-ops-ext.csv +4 -0
  54. data/spec/data/tree-ops-ext.json +81 -0
  55. data/spec/data/tree-ops-minimal.json +18 -0
  56. data/spec/data/tree-ops-minimal.ttl +14 -0
  57. data/spec/data/tree-ops-standard.json +44 -0
  58. data/spec/data/tree-ops-standard.ttl +44 -0
  59. data/spec/data/tree-ops-virtual-minimal.json +32 -0
  60. data/spec/data/tree-ops-virtual-minimal.ttl +25 -0
  61. data/spec/data/tree-ops-virtual-standard.json +49 -0
  62. data/spec/data/tree-ops-virtual-standard.ttl +49 -0
  63. data/spec/data/tree-ops-virtual.json +48 -0
  64. data/spec/data/tree-ops.csv +3 -0
  65. data/spec/data/tree-ops.csv-metadata.json +43 -0
  66. data/spec/data/tree-ops.html +54 -0
  67. data/spec/data/tree-ops.tsv +3 -0
  68. data/spec/format_spec.rb +5 -4
  69. data/spec/metadata_spec.rb +10 -16
  70. data/spec/suite_helper.rb +2 -2
  71. data/spec/suite_spec.rb +5 -6
  72. data/spec/uax35_spec.rb +239 -0
  73. metadata +149 -36
  74. data/lib/rdf/tabular/json.rb +0 -0
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "@id": "http://example.org/countries_embed.html#countries_AD",
4
+ "http://www.geonames.org/ontology#countryCode": "AD",
5
+ "schema:latitude": 42.5,
6
+ "schema:longitude": 1.6,
7
+ "schema:name": "Andorra"
8
+ },
9
+ {
10
+ "@id": "http://example.org/countries_embed.html#countries_AE",
11
+ "http://www.geonames.org/ontology#countryCode": "AE",
12
+ "schema:latitude": 23.4,
13
+ "schema:longitude": 53.8,
14
+ "schema:name": "United Arab Emirates"
15
+ },
16
+ {
17
+ "@id": "http://example.org/countries_embed.html#countries_AF",
18
+ "http://www.geonames.org/ontology#countryCode": "AF",
19
+ "schema:latitude": 33.9,
20
+ "schema:longitude": 67.7,
21
+ "schema:name": "Afghanistan"
22
+ },
23
+ {
24
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
25
+ "http://example.org/year": "1960",
26
+ "http://example.org/population": 9616353
27
+ },
28
+ {
29
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
30
+ "http://example.org/year": "1961",
31
+ "http://example.org/population": 9799379
32
+ },
33
+ {
34
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
35
+ "http://example.org/year": "1962",
36
+ "http://example.org/population": 9989846
37
+ }
38
+ ]
@@ -0,0 +1,36 @@
1
+ @prefix geonames: <http://www.geonames.org/ontology#> .
2
+ @prefix schema: <http://schema.org/> .
3
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4
+
5
+ <http://example.org/countries_embed.html#countries_AD> schema:latitude "42.5"^^xsd:double;
6
+ schema:longitude "1.6"^^xsd:double;
7
+ schema:name "Andorra";
8
+ geonames:countryCode "AD" .
9
+
10
+ <http://example.org/countries_embed.html#countries_AE> schema:latitude "23.4"^^xsd:double;
11
+ schema:longitude "53.8"^^xsd:double;
12
+ schema:name "United Arab Emirates";
13
+ geonames:countryCode "AE" .
14
+
15
+ <http://example.org/countries_embed.html#countries_AF> schema:latitude "33.9"^^xsd:double;
16
+ schema:longitude "67.7"^^xsd:double;
17
+ schema:name "Afghanistan";
18
+ geonames:countryCode "AF" .
19
+
20
+ [
21
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
22
+ <http://example.org/population> "9989846"^^xsd:integer;
23
+ <http://example.org/year> "1962"^^xsd:gYear
24
+ ] .
25
+
26
+ [
27
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
28
+ <http://example.org/population> "9799379"^^xsd:integer;
29
+ <http://example.org/year> "1961"^^xsd:gYear
30
+ ] .
31
+
32
+ [
33
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
34
+ <http://example.org/population> "9616353"^^xsd:integer;
35
+ <http://example.org/year> "1960"^^xsd:gYear
36
+ ] .
@@ -0,0 +1,86 @@
1
+ {
2
+ "tables": [
3
+ {
4
+ "url": "http://example.org/countries_embed.html#countries",
5
+ "row": [
6
+ {
7
+ "url": "http://example.org/countries_embed.html#row=5",
8
+ "rownum": 5,
9
+ "describes": [
10
+ {
11
+ "@id": "http://example.org/countries_embed.html#countries_AD",
12
+ "http://www.geonames.org/ontology#countryCode": "AD",
13
+ "schema:latitude": 42.5,
14
+ "schema:longitude": 1.6,
15
+ "schema:name": "Andorra"
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ "url": "http://example.org/countries_embed.html#row=6",
21
+ "rownum": 6,
22
+ "describes": [
23
+ {
24
+ "@id": "http://example.org/countries_embed.html#countries_AE",
25
+ "http://www.geonames.org/ontology#countryCode": "AE",
26
+ "schema:latitude": 23.4,
27
+ "schema:longitude": 53.8,
28
+ "schema:name": "United Arab Emirates"
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "url": "http://example.org/countries_embed.html#row=7",
34
+ "rownum": 7,
35
+ "describes": [
36
+ {
37
+ "@id": "http://example.org/countries_embed.html#countries_AF",
38
+ "http://www.geonames.org/ontology#countryCode": "AF",
39
+ "schema:latitude": 33.9,
40
+ "schema:longitude": 67.7,
41
+ "schema:name": "Afghanistan"
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "url": "http://example.org/countries_embed.html#country_slice",
49
+ "row": [
50
+ {
51
+ "url": "http://example.org/countries_embed.html#row=5",
52
+ "rownum": 5,
53
+ "describes": [
54
+ {
55
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
56
+ "http://example.org/year": "1960",
57
+ "http://example.org/population": 9616353
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "url": "http://example.org/countries_embed.html#row=6",
63
+ "rownum": 6,
64
+ "describes": [
65
+ {
66
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
67
+ "http://example.org/year": "1961",
68
+ "http://example.org/population": 9799379
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "url": "http://example.org/countries_embed.html#row=7",
74
+ "rownum": 7,
75
+ "describes": [
76
+ {
77
+ "http://example.org/countryRef": "http://example.org/countries_embed.html#countries_AF",
78
+ "http://example.org/year": "1962",
79
+ "http://example.org/population": 9989846
80
+ }
81
+ ]
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }
@@ -0,0 +1,75 @@
1
+ @prefix csvw: <http://www.w3.org/ns/csvw#> .
2
+ @prefix geonames: <http://www.geonames.org/ontology#> .
3
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4
+ @prefix schema: <http://schema.org/> .
5
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
6
+
7
+ <http://example.org/countries_embed.html#countries_AD> schema:latitude "42.5"^^xsd:double;
8
+ schema:longitude "1.6"^^xsd:double;
9
+ schema:name "Andorra";
10
+ geonames:countryCode "AD" .
11
+
12
+ <http://example.org/countries_embed.html#countries_AE> schema:latitude "23.4"^^xsd:double;
13
+ schema:longitude "53.8"^^xsd:double;
14
+ schema:name "United Arab Emirates";
15
+ geonames:countryCode "AE" .
16
+
17
+ <http://example.org/countries_embed.html#countries_AF> schema:latitude "33.9"^^xsd:double;
18
+ schema:longitude "67.7"^^xsd:double;
19
+ schema:name "Afghanistan";
20
+ geonames:countryCode "AF" .
21
+
22
+ [
23
+ a csvw:TableGroup;
24
+ csvw:table [
25
+ a csvw:Table;
26
+ csvw:row [
27
+ a csvw:Row;
28
+ csvw:describes <http://example.org/countries_embed.html#countries_AD>;
29
+ csvw:rownum "5"^^xsd:integer;
30
+ csvw:url <http://example.org/countries_embed.html#row=5>
31
+ ], [
32
+ a csvw:Row;
33
+ csvw:describes <http://example.org/countries_embed.html#countries_AE>;
34
+ csvw:rownum "6"^^xsd:integer;
35
+ csvw:url <http://example.org/countries_embed.html#row=6>
36
+ ], [
37
+ a csvw:Row;
38
+ csvw:describes <http://example.org/countries_embed.html#countries_AF>;
39
+ csvw:rownum "7"^^xsd:integer;
40
+ csvw:url <http://example.org/countries_embed.html#row=7>
41
+ ];
42
+ csvw:url <http://example.org/countries_embed.html#countries>
43
+ ], [
44
+ a csvw:Table;
45
+ csvw:row [
46
+ a csvw:Row;
47
+ csvw:describes [
48
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
49
+ <http://example.org/population> "9616353"^^xsd:integer;
50
+ <http://example.org/year> "1960"^^xsd:gYear
51
+ ];
52
+ csvw:rownum "5"^^xsd:integer;
53
+ csvw:url <http://example.org/countries_embed.html#row=5>
54
+ ], [
55
+ a csvw:Row;
56
+ csvw:describes [
57
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
58
+ <http://example.org/population> "9799379"^^xsd:integer;
59
+ <http://example.org/year> "1961"^^xsd:gYear
60
+ ];
61
+ csvw:rownum "6"^^xsd:integer;
62
+ csvw:url <http://example.org/countries_embed.html#row=6>
63
+ ], [
64
+ a csvw:Row;
65
+ csvw:describes [
66
+ <http://example.org/countryRef> <http://example.org/countries_embed.html#countries_AF>;
67
+ <http://example.org/population> "9989846"^^xsd:integer;
68
+ <http://example.org/year> "1962"^^xsd:gYear
69
+ ];
70
+ csvw:rownum "7"^^xsd:integer;
71
+ csvw:url <http://example.org/countries_embed.html#row=7>
72
+ ];
73
+ csvw:url <http://example.org/countries_embed.html#country_slice>
74
+ ]
75
+ ] .
@@ -0,0 +1,88 @@
1
+ <html>
2
+ <head>
3
+ <title>Example of CSVW metadata in HTML referencing HTML tables</title>
4
+ <style type="text/css">
5
+ /* Style Turtle script blocks to be visable */
6
+ pre.example script {
7
+ display:block;
8
+ }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <p>This shows an example of embeddeding CSV metadata within an HTML document referencing the following HTML tables which contains the following:</p>
13
+ <table id="countries">
14
+ <caption>Countries</caption>
15
+ <tr><th>countryCode</th><th>latitude</th><th>longitude</th><th>name</th></tr>
16
+ <tr><td>AD</td><td>42.5</td><td>1.6</td><td>Andorra</td></tr>
17
+ <tr><td>AE</td><td>23.4</td><td>53.8</td><td>United Arab Emirates</td></tr>
18
+ <tr><td>AF</td><td>33.9</td><td>67.7</td><td>Afghanistan</td></tr>
19
+ </table>
20
+ <table id="country_slice">
21
+ <caption>Country Slice</caption>
22
+ <tr><th>countryRef</th><th>year</th><th>population</th></tr>
23
+ <tr><td>AF</td><td>1960</td><td>9616353</td></tr>
24
+ <tr><td>AF</td><td>1961</td><td>9799379</td></tr>
25
+ <tr><td>AF</td><td>1962</td><td>9989846</td></tr>
26
+ </table>
27
+ <p>The metadata is describe here in a script element:</p>
28
+ <pre class="example">
29
+ <script type="application/csvm+json">
30
+ {
31
+ "@context": "http://www.w3.org/ns/csvw",
32
+ "tables": [{
33
+ "url": "#countries",
34
+ "tableSchema": {
35
+ "columns": [{
36
+ "name": "countryCode",
37
+ "titles": "countryCode",
38
+ "datatype": "string",
39
+ "propertyUrl": "http://www.geonames.org/ontology{#_name}"
40
+ }, {
41
+ "name": "latitude",
42
+ "titles": "latitude",
43
+ "datatype": "number"
44
+ }, {
45
+ "name": "longitude",
46
+ "titles": "longitude",
47
+ "datatype": "number"
48
+ }, {
49
+ "name": "name",
50
+ "titles": "name",
51
+ "datatype": "string"
52
+ }],
53
+ "aboutUrl": "#countries_{countryCode}",
54
+ "propertyUrl": "http://schema.org/{_name}",
55
+ "primaryKey": "countryCode"
56
+ }
57
+ }, {
58
+ "url": "#country_slice",
59
+ "tableSchema": {
60
+ "columns": [{
61
+ "name": "countryRef",
62
+ "titles": "countryRef",
63
+ "valueUrl": "#countries_{countryRef}"
64
+ }, {
65
+ "name": "year",
66
+ "titles": "year",
67
+ "datatype": "gYear"
68
+ }, {
69
+ "name": "population",
70
+ "titles": "population",
71
+ "datatype": "integer"
72
+ }],
73
+ "propertyUrl": "http://example.org/{_name}",
74
+ "foreignKeys": [{
75
+ "columnReference": "countryRef",
76
+ "reference": {
77
+ "resource": "#countries",
78
+ "columnReference": "countryCode"
79
+ }
80
+ }]
81
+ }
82
+ }]
83
+ }
84
+ </script>
85
+ </pre>
86
+ <p>The metadata is also <a rel="describedby" href="countries.json">described in JSON</a>.</p>
87
+ </body>
88
+ </html>
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "@id": "http://example.org/countries.csv#AD",
4
+ "http://www.geonames.org/ontology#countryCode": "AD",
5
+ "schema:latitude": 42.546245,
6
+ "schema:longitude": 1.601554,
7
+ "schema:name": "Andorra"
8
+ },
9
+ {
10
+ "@id": "http://example.org/countries.csv#AE",
11
+ "http://www.geonames.org/ontology#countryCode": "AE",
12
+ "schema:latitude": 23.424076,
13
+ "schema:longitude": 53.847818,
14
+ "schema:name": "United Arab Emirates"
15
+ },
16
+ {
17
+ "@id": "http://example.org/countries.csv#AF",
18
+ "http://www.geonames.org/ontology#countryCode": "AF",
19
+ "schema:latitude": 33.93911,
20
+ "schema:longitude": 67.709953,
21
+ "schema:name": "Afghanistan"
22
+ },
23
+ {
24
+ "countryRef": "http://example.org/countries.csv#AF",
25
+ "year": "1960",
26
+ "population": 9616353
27
+ },
28
+ {
29
+ "countryRef": "http://example.org/countries.csv#AF",
30
+ "year": "1961",
31
+ "population": 9799379
32
+ },
33
+ {
34
+ "countryRef": "http://example.org/countries.csv#AF",
35
+ "year": "1962",
36
+ "population": 9989846
37
+ }
38
+ ]
@@ -0,0 +1,36 @@
1
+ @prefix geonames: <http://www.geonames.org/ontology#> .
2
+ @prefix schema: <http://schema.org/> .
3
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4
+
5
+ <http://example.org/countries.csv#AD> schema:latitude "42.546245"^^xsd:double;
6
+ schema:longitude "1.601554"^^xsd:double;
7
+ schema:name "Andorra";
8
+ geonames:countryCode "AD" .
9
+
10
+ <http://example.org/countries.csv#AE> schema:latitude "23.424076"^^xsd:double;
11
+ schema:longitude "53.847818"^^xsd:double;
12
+ schema:name "United Arab Emirates";
13
+ geonames:countryCode "AE" .
14
+
15
+ <http://example.org/countries.csv#AF> schema:latitude "33.93911"^^xsd:double;
16
+ schema:longitude "67.709953"^^xsd:double;
17
+ schema:name "Afghanistan";
18
+ geonames:countryCode "AF" .
19
+
20
+ [
21
+ <http://example.org/country_slice.csv#countryRef> <http://example.org/countries.csv#AF>;
22
+ <http://example.org/country_slice.csv#population> "9989846"^^xsd:integer;
23
+ <http://example.org/country_slice.csv#year> "1962"^^xsd:gYear
24
+ ] .
25
+
26
+ [
27
+ <http://example.org/country_slice.csv#countryRef> <http://example.org/countries.csv#AF>;
28
+ <http://example.org/country_slice.csv#population> "9799379"^^xsd:integer;
29
+ <http://example.org/country_slice.csv#year> "1961"^^xsd:gYear
30
+ ] .
31
+
32
+ [
33
+ <http://example.org/country_slice.csv#countryRef> <http://example.org/countries.csv#AF>;
34
+ <http://example.org/country_slice.csv#population> "9616353"^^xsd:integer;
35
+ <http://example.org/country_slice.csv#year> "1960"^^xsd:gYear
36
+ ] .
@@ -0,0 +1,86 @@
1
+ {
2
+ "tables": [
3
+ {
4
+ "url": "http://example.org/countries.csv",
5
+ "row": [
6
+ {
7
+ "url": "http://example.org/countries.csv#row=2",
8
+ "rownum": 1,
9
+ "describes": [
10
+ {
11
+ "@id": "http://example.org/countries.csv#AD",
12
+ "http://www.geonames.org/ontology#countryCode": "AD",
13
+ "schema:latitude": 42.546245,
14
+ "schema:longitude": 1.601554,
15
+ "schema:name": "Andorra"
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ "url": "http://example.org/countries.csv#row=3",
21
+ "rownum": 2,
22
+ "describes": [
23
+ {
24
+ "@id": "http://example.org/countries.csv#AE",
25
+ "http://www.geonames.org/ontology#countryCode": "AE",
26
+ "schema:latitude": 23.424076,
27
+ "schema:longitude": 53.847818,
28
+ "schema:name": "United Arab Emirates"
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "url": "http://example.org/countries.csv#row=4",
34
+ "rownum": 3,
35
+ "describes": [
36
+ {
37
+ "@id": "http://example.org/countries.csv#AF",
38
+ "http://www.geonames.org/ontology#countryCode": "AF",
39
+ "schema:latitude": 33.93911,
40
+ "schema:longitude": 67.709953,
41
+ "schema:name": "Afghanistan"
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "url": "http://example.org/country_slice.csv",
49
+ "row": [
50
+ {
51
+ "url": "http://example.org/country_slice.csv#row=2",
52
+ "rownum": 1,
53
+ "describes": [
54
+ {
55
+ "countryRef": "http://example.org/countries.csv#AF",
56
+ "year": "1960",
57
+ "population": 9616353
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "url": "http://example.org/country_slice.csv#row=3",
63
+ "rownum": 2,
64
+ "describes": [
65
+ {
66
+ "countryRef": "http://example.org/countries.csv#AF",
67
+ "year": "1961",
68
+ "population": 9799379
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "url": "http://example.org/country_slice.csv#row=4",
74
+ "rownum": 3,
75
+ "describes": [
76
+ {
77
+ "countryRef": "http://example.org/countries.csv#AF",
78
+ "year": "1962",
79
+ "population": 9989846
80
+ }
81
+ ]
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }