eyeling 1.24.3 → 1.24.4
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.
- package/HANDBOOK.md +2 -2
- package/dist/browser/eyeling.browser.js +1 -1
- package/eyeling.js +1 -1
- package/lib/lexer.js +1 -1
- package/package.json +2 -3
- package/see/README.md +1 -1
- package/see/examples/input/path_discovery.trig +1 -1
- package/see/see.js +1 -1
- package/test/n3gen.test.js +0 -166
- package/tools/n3gen.js +0 -2166
package/HANDBOOK.md
CHANGED
|
@@ -251,7 +251,7 @@ is treated internally like:
|
|
|
251
251
|
:observation rdf:reifies { :sensor :reports :overheating } .
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
RDF/TriG named graph blocks are normalized
|
|
254
|
+
RDF/TriG named graph blocks are normalized to ordinary N3 graph terms:
|
|
255
255
|
|
|
256
256
|
```trig
|
|
257
257
|
:factoryDataset {
|
|
@@ -3883,7 +3883,7 @@ In RDF compatibility mode, Eyeling accepts this surface form by translating the
|
|
|
3883
3883
|
:observation rdf:reifies { :sensor :reports :overheating } .
|
|
3884
3884
|
```
|
|
3885
3885
|
|
|
3886
|
-
The dataset example also uses named graph syntax, which RDF compatibility mode normalizes to `log:nameOf` graph terms
|
|
3886
|
+
The dataset example also uses named graph syntax, which RDF compatibility mode normalizes to `log:nameOf` graph terms:
|
|
3887
3887
|
|
|
3888
3888
|
```trig
|
|
3889
3889
|
:factoryDataset {
|
|
@@ -9588,7 +9588,7 @@ function stripQuotes(lex) {
|
|
|
9588
9588
|
// - RDF 1.2 triple terms <<( s p o )>> become singleton graph terms { s p o }.
|
|
9589
9589
|
// - TriG named graph blocks g { ... } become g log:nameOf { ... } .
|
|
9590
9590
|
// - A top-level default graph block { ... } is unwrapped into ordinary triples.
|
|
9591
|
-
// This
|
|
9591
|
+
// This keeps all downstream parsing/reasoning N3-only.
|
|
9592
9592
|
const LOG_NAME_OF_IRI = '<http://www.w3.org/2000/10/swap/log#nameOf>';
|
|
9593
9593
|
|
|
9594
9594
|
function normalizeRdfCompatibility(inputText) {
|
package/eyeling.js
CHANGED
|
@@ -9588,7 +9588,7 @@ function stripQuotes(lex) {
|
|
|
9588
9588
|
// - RDF 1.2 triple terms <<( s p o )>> become singleton graph terms { s p o }.
|
|
9589
9589
|
// - TriG named graph blocks g { ... } become g log:nameOf { ... } .
|
|
9590
9590
|
// - A top-level default graph block { ... } is unwrapped into ordinary triples.
|
|
9591
|
-
// This
|
|
9591
|
+
// This keeps all downstream parsing/reasoning N3-only.
|
|
9592
9592
|
const LOG_NAME_OF_IRI = '<http://www.w3.org/2000/10/swap/log#nameOf>';
|
|
9593
9593
|
|
|
9594
9594
|
function normalizeRdfCompatibility(inputText) {
|
package/lib/lexer.js
CHANGED
|
@@ -353,7 +353,7 @@ function stripQuotes(lex) {
|
|
|
353
353
|
// - RDF 1.2 triple terms <<( s p o )>> become singleton graph terms { s p o }.
|
|
354
354
|
// - TriG named graph blocks g { ... } become g log:nameOf { ... } .
|
|
355
355
|
// - A top-level default graph block { ... } is unwrapped into ordinary triples.
|
|
356
|
-
// This
|
|
356
|
+
// This keeps all downstream parsing/reasoning N3-only.
|
|
357
357
|
const LOG_NAME_OF_IRI = '<http://www.w3.org/2000/10/swap/log#nameOf>';
|
|
358
358
|
|
|
359
359
|
function normalizeRdfCompatibility(inputText) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyeling",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.4",
|
|
4
4
|
"description": "A minimal Notation3 (N3) reasoner in JavaScript.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -44,14 +44,13 @@
|
|
|
44
44
|
"test:packlist": "node test/packlist.test.js",
|
|
45
45
|
"test:api": "node test/api.test.js",
|
|
46
46
|
"test:builtins": "node test/builtins.test.js",
|
|
47
|
-
"test:n3gen": "node test/n3gen.test.js",
|
|
48
47
|
"test:examples": "node test/examples.test.js",
|
|
49
48
|
"test:see": "node test/see.test.js",
|
|
50
49
|
"test:manifest": "node test/manifest.test.js",
|
|
51
50
|
"test:playground": "node test/playground.test.js",
|
|
52
51
|
"test:package": "node test/package.test.js",
|
|
53
52
|
"pretest": "npm run build && npm run test:packlist",
|
|
54
|
-
"test": "npm run test:api && npm run test:builtins && npm run test:
|
|
53
|
+
"test": "npm run test:api && npm run test:builtins && npm run test:examples && npm run test:see && npm run test:manifest && npm run test:playground",
|
|
55
54
|
"posttest": "npm run test:package",
|
|
56
55
|
"preversion": "npm test",
|
|
57
56
|
"postversion": "git push origin HEAD --follow-tags"
|
package/see/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Each example starts from a Notation3 source and is compiled by `see.js` into a s
|
|
|
18
18
|
|
|
19
19
|
The trust gate is executable verification. If a required fact is missing, the program fails instead of emitting an unsupported entailment.
|
|
20
20
|
|
|
21
|
-
The `triple_terms` and `rdf_dataset` examples use RDF 1.2 `<<( ... )>>` triple-term syntax. Eyeling accepts that syntax only with `-r, --rdf`, where it normalizes triple terms to existing N3 singleton graph terms `{ ... }` and prints feasible output graph terms back as RDF 1.2 triple terms. The `rdf_dataset` example also uses an RDF/TriG named graph block, which RDF compatibility mode normalizes to the
|
|
21
|
+
The `triple_terms` and `rdf_dataset` examples use RDF 1.2 `<<( ... )>>` triple-term syntax. Eyeling accepts that syntax only with `-r, --rdf`, where it normalizes triple terms to existing N3 singleton graph terms `{ ... }` and prints feasible output graph terms back as RDF 1.2 triple terms. The `rdf_dataset` example also uses an RDF/TriG named graph block, which RDF compatibility mode normalizes to the N3 `log:nameOf { ... }` graph-term shape and prints back as a TriG named graph block where feasible; SEE keeps the committed `.trig` input and formal output in RDF 1.2/TriG form.
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
## Run
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@prefix in: <https://example.org/see/input#> .
|
|
10
10
|
|
|
11
11
|
# Formal SEE input evidence in RDF 1.2 TriG.
|
|
12
|
-
# The generated runner
|
|
12
|
+
# The generated runner reads this TriG evidence directly in RDF compatibility mode.
|
|
13
13
|
|
|
14
14
|
# No source facts were present in the N3 program.
|
|
15
15
|
|
package/see/see.js
CHANGED
|
@@ -554,7 +554,7 @@ function compilationStats(program) {
|
|
|
554
554
|
|
|
555
555
|
// Source facts are emitted as RDF 1.2 TriG. Formulas that appear as objects are
|
|
556
556
|
// lifted into named graphs so the generated runner can load evidence directly
|
|
557
|
-
// from .trig without going through an intermediate
|
|
557
|
+
// from .trig without going through an intermediate conversion step.
|
|
558
558
|
function trigString(value) {
|
|
559
559
|
return JSON.stringify(String(value));
|
|
560
560
|
}
|
package/test/n3gen.test.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// Convert examples/input/*.{ttl,trig} -> examples/*.n3 using n3gen.js
|
|
5
|
-
//
|
|
6
|
-
// For reproducibility and to avoid mutating tracked files during tests, generated output
|
|
7
|
-
// is always written to a temporary file and compared against examples/<name>.n3.
|
|
8
|
-
|
|
9
|
-
const fs = require('node:fs');
|
|
10
|
-
const os = require('node:os');
|
|
11
|
-
const path = require('node:path');
|
|
12
|
-
const cp = require('node:child_process');
|
|
13
|
-
|
|
14
|
-
const TTY = process.stdout.isTTY;
|
|
15
|
-
const C = TTY
|
|
16
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
17
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
18
|
-
|
|
19
|
-
function ok(msg) {
|
|
20
|
-
console.log(`${C.g}OK ${C.n} ${msg}`);
|
|
21
|
-
}
|
|
22
|
-
function fail(msg) {
|
|
23
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
24
|
-
}
|
|
25
|
-
function info(msg) {
|
|
26
|
-
console.log(`${C.y}==${C.n} ${msg}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function run(cmd, args, opts = {}) {
|
|
30
|
-
return cp.spawnSync(cmd, args, {
|
|
31
|
-
encoding: 'utf8',
|
|
32
|
-
maxBuffer: 200 * 1024 * 1024,
|
|
33
|
-
...opts,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function mkTmpDir() {
|
|
38
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), 'eyeling-n3-'));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function rmrf(p) {
|
|
42
|
-
try {
|
|
43
|
-
fs.rmSync(p, { recursive: true, force: true });
|
|
44
|
-
} catch {}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function showDiff({ examplesDir, expectedPath, generatedPath }) {
|
|
48
|
-
const d = run('diff', ['-u', expectedPath, generatedPath], { cwd: examplesDir });
|
|
49
|
-
if (d.stdout) process.stdout.write(d.stdout);
|
|
50
|
-
if (d.stderr) process.stderr.write(d.stderr);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function main() {
|
|
54
|
-
const suiteStart = Date.now();
|
|
55
|
-
|
|
56
|
-
// test/n3gen.test.js -> repo root is one level up
|
|
57
|
-
const root = path.resolve(__dirname, '..');
|
|
58
|
-
const examplesDir = path.join(root, 'examples');
|
|
59
|
-
const inputDir = path.join(examplesDir, 'input');
|
|
60
|
-
const n3GenJsPath = path.join(root, 'tools/n3gen.js');
|
|
61
|
-
const nodePath = process.execPath;
|
|
62
|
-
|
|
63
|
-
if (!fs.existsSync(examplesDir)) {
|
|
64
|
-
fail(`Cannot find examples directory: ${examplesDir}`);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
if (!fs.existsSync(inputDir)) {
|
|
68
|
-
fail(`Cannot find examples/input directory: ${inputDir}`);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
if (!fs.existsSync(n3GenJsPath)) {
|
|
72
|
-
fail(`Cannot find n3gen.js: ${n3GenJsPath}`);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const inputs = fs
|
|
77
|
-
.readdirSync(inputDir)
|
|
78
|
-
.filter((f) => /\.(ttl|trig)$/i.test(f))
|
|
79
|
-
.sort((a, b) => a.localeCompare(b));
|
|
80
|
-
|
|
81
|
-
info(`Running n3 conversions for ${inputs.length} inputs`);
|
|
82
|
-
console.log(`${C.dim}node ${process.version}${C.n}`);
|
|
83
|
-
|
|
84
|
-
if (inputs.length === 0) {
|
|
85
|
-
ok('No .ttl/.trig files found in examples/input/');
|
|
86
|
-
process.exit(0);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let passed = 0;
|
|
90
|
-
let failed = 0;
|
|
91
|
-
|
|
92
|
-
for (let i = 0; i < inputs.length; i++) {
|
|
93
|
-
const idx = String(i + 1).padStart(2, '0');
|
|
94
|
-
const inFile = inputs[i];
|
|
95
|
-
const start = Date.now();
|
|
96
|
-
|
|
97
|
-
const inPath = path.join(inputDir, inFile);
|
|
98
|
-
const base = inFile.replace(/\.(ttl|trig)$/i, '');
|
|
99
|
-
const outFile = `${base}.n3`;
|
|
100
|
-
|
|
101
|
-
const expectedPath = path.join(examplesDir, outFile);
|
|
102
|
-
|
|
103
|
-
if (!fs.existsSync(expectedPath)) {
|
|
104
|
-
const ms = Date.now() - start;
|
|
105
|
-
fail(`${idx} ${inFile} -> ${outFile} (${ms} ms)`);
|
|
106
|
-
fail(`Missing expected examples/${outFile}`);
|
|
107
|
-
failed++;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const tmpDir = mkTmpDir();
|
|
112
|
-
const generatedPath = path.join(tmpDir, outFile);
|
|
113
|
-
|
|
114
|
-
// Run converter (stdout -> file; stderr captured)
|
|
115
|
-
const outFd = fs.openSync(generatedPath, 'w');
|
|
116
|
-
const r = cp.spawnSync(nodePath, [n3GenJsPath, inPath], {
|
|
117
|
-
cwd: root,
|
|
118
|
-
stdio: ['ignore', outFd, 'pipe'],
|
|
119
|
-
encoding: 'utf8',
|
|
120
|
-
maxBuffer: 200 * 1024 * 1024,
|
|
121
|
-
});
|
|
122
|
-
fs.closeSync(outFd);
|
|
123
|
-
|
|
124
|
-
const rc = r.status == null ? 1 : r.status;
|
|
125
|
-
const ms = Date.now() - start;
|
|
126
|
-
|
|
127
|
-
if (rc !== 0) {
|
|
128
|
-
fail(`${idx} ${inFile} -> ${outFile} (${ms} ms)`);
|
|
129
|
-
fail(`Converter exit code ${rc}`);
|
|
130
|
-
if (r.stderr) process.stderr.write(String(r.stderr));
|
|
131
|
-
failed++;
|
|
132
|
-
rmrf(tmpDir);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Compare output (always compare expected vs generated temp file)
|
|
137
|
-
const d = run('diff', ['-u', expectedPath, generatedPath], { cwd: examplesDir });
|
|
138
|
-
const diffOk = d.status === 0;
|
|
139
|
-
|
|
140
|
-
if (diffOk) {
|
|
141
|
-
ok(`${idx} ${inFile} -> ${outFile} (${ms} ms)`);
|
|
142
|
-
passed++;
|
|
143
|
-
} else {
|
|
144
|
-
fail(`${idx} ${inFile} -> ${outFile} (${ms} ms)`);
|
|
145
|
-
fail('Output differs');
|
|
146
|
-
showDiff({ examplesDir, expectedPath, generatedPath });
|
|
147
|
-
failed++;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
rmrf(tmpDir);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
console.log('');
|
|
154
|
-
const suiteMs = Date.now() - suiteStart;
|
|
155
|
-
info(`Total elapsed: ${suiteMs} ms (${(suiteMs / 1000).toFixed(2)} s)`);
|
|
156
|
-
|
|
157
|
-
if (failed === 0) {
|
|
158
|
-
ok(`All n3 conversions passed (${passed}/${inputs.length})`);
|
|
159
|
-
process.exit(0);
|
|
160
|
-
} else {
|
|
161
|
-
fail(`Some n3 conversions failed (${passed}/${inputs.length})`);
|
|
162
|
-
process.exit(2);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
main();
|