eyeling 1.30.5 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +0 -157
  2. package/dist/browser/eyeling.browser.js +13 -561
  3. package/eyeling.js +13 -561
  4. package/index.d.ts +0 -4
  5. package/index.js +1 -2
  6. package/lib/cli.js +4 -11
  7. package/lib/engine.js +6 -14
  8. package/lib/lexer.js +0 -4
  9. package/lib/multisource.js +3 -5
  10. package/package.json +3 -6
  11. package/test/examples.test.js +5 -37
  12. package/test/playground.test.js +1 -1
  13. package/test/run.js +60 -0
  14. package/examples/input/rdf-surfaces-all-values-from-reverse.ttl +0 -17
  15. package/examples/input/rdf-surfaces-all-values-from.ttl +0 -13
  16. package/examples/input/rdf-surfaces-ancestor.ttl +0 -20
  17. package/examples/input/rdf-surfaces-city.ttl +0 -11
  18. package/examples/input/rdf-surfaces-disjunction-elimination.ttl +0 -16
  19. package/examples/input/rdf-surfaces-disjunction-route-filter.ttl +0 -11
  20. package/examples/input/rdf-surfaces-domain.ttl +0 -11
  21. package/examples/input/rdf-surfaces-explicit-disjunction.ttl +0 -22
  22. package/examples/input/rdf-surfaces-multi-premise.ttl +0 -13
  23. package/examples/input/rdf-surfaces-owl-all-values-from-codex.ttl +0 -35
  24. package/examples/input/rdf-surfaces-property-chain.ttl +0 -13
  25. package/examples/input/rdf-surfaces-range.ttl +0 -11
  26. package/examples/input/rdf-surfaces-rdfs-range-codex.ttl +0 -18
  27. package/examples/input/rdf-surfaces-rdfs-subclass-codex.ttl +0 -18
  28. package/examples/input/rdf-surfaces-strong-negation-access.ttl +0 -14
  29. package/examples/output/rdf-surfaces-all-values-from-reverse.n3 +0 -3
  30. package/examples/output/rdf-surfaces-all-values-from.n3 +0 -3
  31. package/examples/output/rdf-surfaces-ancestor.n3 +0 -5
  32. package/examples/output/rdf-surfaces-city.n3 +0 -3
  33. package/examples/output/rdf-surfaces-disjunction-elimination.n3 +0 -3
  34. package/examples/output/rdf-surfaces-disjunction-route-filter.n3 +0 -3
  35. package/examples/output/rdf-surfaces-domain.n3 +0 -3
  36. package/examples/output/rdf-surfaces-explicit-disjunction.n3 +0 -3
  37. package/examples/output/rdf-surfaces-multi-premise.n3 +0 -3
  38. package/examples/output/rdf-surfaces-owl-all-values-from-codex.n3 +0 -6
  39. package/examples/output/rdf-surfaces-property-chain.n3 +0 -3
  40. package/examples/output/rdf-surfaces-range.n3 +0 -3
  41. package/examples/output/rdf-surfaces-rdfs-range-codex.n3 +0 -3
  42. package/examples/output/rdf-surfaces-rdfs-subclass-codex.n3 +0 -3
  43. package/examples/output/rdf-surfaces-strong-negation-access.n3 +0 -4
  44. package/examples/rdf-surfaces-all-values-from-reverse.n3 +0 -6
  45. package/examples/rdf-surfaces-all-values-from.n3 +0 -6
  46. package/examples/rdf-surfaces-ancestor.n3 +0 -6
  47. package/examples/rdf-surfaces-city.n3 +0 -6
  48. package/examples/rdf-surfaces-disjunction-elimination.n3 +0 -13
  49. package/examples/rdf-surfaces-disjunction-route-filter.n3 +0 -24
  50. package/examples/rdf-surfaces-domain.n3 +0 -6
  51. package/examples/rdf-surfaces-explicit-disjunction.n3 +0 -16
  52. package/examples/rdf-surfaces-multi-premise.n3 +0 -6
  53. package/examples/rdf-surfaces-owl-all-values-from-codex.n3 +0 -10
  54. package/examples/rdf-surfaces-property-chain.n3 +0 -6
  55. package/examples/rdf-surfaces-range.n3 +0 -6
  56. package/examples/rdf-surfaces-rdfs-range-codex.n3 +0 -6
  57. package/examples/rdf-surfaces-rdfs-subclass-codex.n3 +0 -6
  58. package/examples/rdf-surfaces-strong-negation-access.n3 +0 -20
  59. package/lib/rdf_surfaces.js +0 -524
  60. package/test/rdf_surfaces.test.js +0 -214
@@ -1,214 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const assert = require('node:assert/strict');
5
- const cp = require('node:child_process');
6
- const path = require('node:path');
7
-
8
- const { reason } = require('../index.js');
9
- const { C, failResult, pass } = require('./report');
10
-
11
- const ROOT = path.resolve(__dirname, '..');
12
- const EYELING = path.join(ROOT, 'eyeling.js');
13
-
14
- function runCli(input, args = ['--rdf-surfaces']) {
15
- return cp.spawnSync(process.execPath, [EYELING, ...args, '-'], {
16
- input,
17
- encoding: 'utf8',
18
- maxBuffer: 20 * 1024 * 1024,
19
- });
20
- }
21
-
22
- function runExample(name) {
23
- return cp.spawnSync(
24
- process.execPath,
25
- [EYELING, '--rdf-surfaces', path.join(ROOT, 'examples', 'input', `${name}.ttl`), path.join(ROOT, 'examples', `${name}.n3`)],
26
- { encoding: 'utf8', maxBuffer: 20 * 1024 * 1024 },
27
- );
28
- }
29
-
30
- const inlineCases = [
31
- {
32
- name: 'slide32-style surface derives subclass instance',
33
- input: `
34
- @prefix ex: <http://example.org/> .
35
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
36
-
37
- ex:Brussels a ex:City .
38
-
39
- %not[ _:x
40
- _:x a ex:City .
41
- %not[
42
- _:x a ex:HumanCommunity .
43
- %]
44
- %]
45
-
46
- { ?s a ex:HumanCommunity . } log:query { ?s a ex:HumanCommunity . } .
47
- `,
48
- expect: '@prefix ex: <http://example.org/> .\n\nex:Brussels a ex:HumanCommunity .',
49
- },
50
- {
51
- name: 'slide33 range-style surface derives object type',
52
- input: `
53
- @prefix ex: <http://example.org/> .
54
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
55
-
56
- ex:alice ex:parent ex:bob .
57
-
58
- %not[ _:x _:y
59
- _:x ex:parent _:y .
60
- %not[
61
- _:y a ex:Person .
62
- %]
63
- %]
64
-
65
- { ?s a ex:Person . } log:query { ?s a ex:Person . } .
66
- `,
67
- expect: '@prefix ex: <http://example.org/> .\n\nex:bob a ex:Person .',
68
- },
69
- {
70
- name: 'slide33 allValuesFrom forward surface derives filler type',
71
- input: `
72
- @prefix ex: <http://example.org/> .
73
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
74
-
75
- ex:box a ex:AllowedContainer .
76
- ex:box ex:contains ex:item42 .
77
-
78
- %not[ _:x _:y
79
- _:x a ex:AllowedContainer .
80
- _:x ex:contains _:y .
81
- %not[
82
- _:y a ex:AllowedItem .
83
- %]
84
- %]
85
-
86
- { ?s a ex:AllowedItem . } log:query { ?s a ex:AllowedItem . } .
87
- `,
88
- expect: '@prefix ex: <http://example.org/> .\n\nex:item42 a ex:AllowedItem .',
89
- },
90
- {
91
- name: 'slide33 allValuesFrom reverse surface derives restricted class',
92
- input: `
93
- @prefix ex: <http://example.org/> .
94
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
95
-
96
- ex:box ex:contains ex:item42 .
97
- ex:item42 a ex:AllowedItem .
98
-
99
- %not[ _:x
100
- %not[ _:y
101
- _:x ex:contains _:y .
102
- %not[
103
- _:y a ex:AllowedItem .
104
- %]
105
- %]
106
- %not[
107
- _:x a ex:AllowedContainer .
108
- %]
109
- %]
110
-
111
- { ?s a ex:AllowedContainer . } log:query { ?s a ex:AllowedContainer . } .
112
- `,
113
- expect: '@prefix ex: <http://example.org/> .\n\nex:box a ex:AllowedContainer .',
114
- },
115
- ];
116
-
117
- const exampleCases = [
118
- ['rdf-surfaces-city', '@prefix ex: <http://example.org/> .\n\nex:Brussels a ex:HumanCommunity .'],
119
- ['rdf-surfaces-range', '@prefix ex: <http://example.org/> .\n\nex:bob a ex:Person .'],
120
- ['rdf-surfaces-domain', '@prefix ex: <http://example.org/> .\n\nex:alice a ex:Member .'],
121
- ['rdf-surfaces-property-chain', '@prefix ex: <http://example.org/> .\n\nex:alice ex:grandparent ex:carol .'],
122
- [
123
- 'rdf-surfaces-ancestor',
124
- '@prefix ex: <http://example.org/> .\n\nex:ann ex:ancestor ex:bob .\nex:bob ex:ancestor ex:cat .\nex:ann ex:ancestor ex:cat .',
125
- ],
126
- ['rdf-surfaces-multi-premise', '@prefix ex: <http://example.org/> .\n\nex:case123 a ex:PriorityCase .'],
127
- ['rdf-surfaces-all-values-from', '@prefix ex: <http://example.org/> .\n\nex:item42 a ex:AllowedItem .'],
128
- ['rdf-surfaces-all-values-from-reverse', '@prefix ex: <http://example.org/> .\n\nex:box a ex:AllowedContainer .'],
129
- ['rdf-surfaces-rdfs-range-codex', '@prefix ex: <http://example.org/> .\n\nex:bob a ex:Person .'],
130
- ['rdf-surfaces-rdfs-subclass-codex', '@prefix ex: <http://example.org/> .\n\nex:Brussels a ex:HumanCommunity .'],
131
- [
132
- 'rdf-surfaces-owl-all-values-from-codex',
133
- '@prefix ex: <http://example.org/> .\n\nex:item43 a ex:AllowedItem .\nex:item42 a ex:AllowedItem .\nex:box a ex:AllowedContainer .\nex:crate a ex:AllowedContainer .',
134
- ],
135
- [
136
- 'rdf-surfaces-strong-negation-access',
137
- '@prefix ex: <http://example.org/> .\n\nex:bob ex:decision ex:Permit .\nex:alice ex:decision ex:Deny .',
138
- ],
139
- ['rdf-surfaces-disjunction-route-filter', '@prefix ex: <http://example.org/> .\n\nex:shipment17 ex:viableRoute ex:Rail .'],
140
- ['rdf-surfaces-explicit-disjunction', '@prefix ex: <http://example.org/> .\n\nex:shipment23 ex:selectedRoute ex:Rail .'],
141
- [
142
- 'rdf-surfaces-disjunction-elimination',
143
- '@prefix ex: <http://example.org/> .\n\nex:caseSplit ex:disjunctionEntails ex:NeedsHumanAttention .',
144
- ],
145
- ];
146
-
147
- let seq = 0;
148
- let failed = 0;
149
-
150
- for (const tc of inlineCases) {
151
- const n = ++seq;
152
- const t0 = Date.now();
153
- try {
154
- const r = runCli(tc.input);
155
- assert.equal(r.status, 0, r.stderr || r.stdout);
156
- assert.equal(r.stdout.trim(), tc.expect);
157
- pass(n, tc.name, Date.now() - t0);
158
- } catch (e) {
159
- failed++;
160
- failResult(n, tc.name, Date.now() - t0);
161
- console.error(`${C.dim}${e && e.stack ? e.stack : String(e)}${C.n}`);
162
- }
163
- }
164
-
165
- for (const [name, expect] of exampleCases) {
166
- const n = ++seq;
167
- const t0 = Date.now();
168
- try {
169
- const r = runExample(name);
170
- assert.equal(r.status, 0, r.stderr || r.stdout);
171
- assert.equal(r.stdout.trim(), expect);
172
- pass(n, `example split input/query ${name}`, Date.now() - t0);
173
- } catch (e) {
174
- failed++;
175
- failResult(n, `example split input/query ${name}`, Date.now() - t0);
176
- console.error(`${C.dim}${e && e.stack ? e.stack : String(e)}${C.n}`);
177
- }
178
- }
179
-
180
- {
181
- const n = ++seq;
182
- const t0 = Date.now();
183
- try {
184
- const out = reason({ rdfSurfaces: true }, inlineCases[0].input).trim();
185
- assert.equal(out, inlineCases[0].expect);
186
- pass(n, 'API rdfSurfaces option implies RDF compatibility', Date.now() - t0);
187
- } catch (e) {
188
- failed++;
189
- failResult(n, 'API rdfSurfaces option implies RDF compatibility', Date.now() - t0);
190
- console.error(`${C.dim}${e && e.stack ? e.stack : String(e)}${C.n}`);
191
- }
192
- }
193
-
194
- {
195
- const n = ++seq;
196
- const t0 = Date.now();
197
- try {
198
- const r = runCli(`
199
- @prefix ex: <http://example.org/> .
200
- ex:bad a ex:Impossible .
201
- %not[ _:x
202
- _:x a ex:Impossible .
203
- %]
204
- `);
205
- assert.equal(r.status, 65, r.stderr || r.stdout);
206
- pass(n, 'top-level negative surface without child is an inference fuse', Date.now() - t0);
207
- } catch (e) {
208
- failed++;
209
- failResult(n, 'top-level negative surface without child is an inference fuse', Date.now() - t0);
210
- console.error(`${C.dim}${e && e.stack ? e.stack : String(e)}${C.n}`);
211
- }
212
- }
213
-
214
- if (failed) process.exit(1);