eyeling 1.6.14 → 1.6.15
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/README.md +8 -19
- package/eyeling.js +32 -7
- package/index.js +13 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,16 +103,16 @@ npm run test:packlist
|
|
|
103
103
|
- `test:package` does a “real consumer” smoke test: `npm pack` → install tarball into a temp project → run API + CLI + examples.
|
|
104
104
|
- `test:packlist` sanity-checks what will be published in the npm tarball (and the CLI shebang/bin wiring).
|
|
105
105
|
|
|
106
|
-
###
|
|
106
|
+
### Usage
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
# Option 1: use the shebang (Unix-like)
|
|
112
|
-
./eyeling.js examples/socrates.n3
|
|
108
|
+
```
|
|
109
|
+
Usage: eyeling.js [options] <file.n3>
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
Options:
|
|
112
|
+
-h, --help Show this help and exit.
|
|
113
|
+
-v, --version Print version and exit.
|
|
114
|
+
-p, --proof-comments Enable proof explanations.
|
|
115
|
+
-n, --no-proof-comments Disable proof explanations (default).
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
By default, `eyeling`:
|
|
@@ -122,17 +122,6 @@ By default, `eyeling`:
|
|
|
122
122
|
3. prints only **newly derived forward facts** (not the original input facts)
|
|
123
123
|
4. prints a compact per-triple explanation as `#` comments (can be disabled)
|
|
124
124
|
|
|
125
|
-
### Options
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
node eyeling.js --version
|
|
129
|
-
node eyeling.js -v
|
|
130
|
-
|
|
131
|
-
# Disable proof comments (print only derived triples)
|
|
132
|
-
node eyeling.js --no-proof-comments examples/socrates.n3
|
|
133
|
-
node eyeling.js -n examples/socrates.n3
|
|
134
|
-
```
|
|
135
|
-
|
|
136
125
|
## What output do I get?
|
|
137
126
|
|
|
138
127
|
For each newly derived triple, `eyeling` prints:
|
package/eyeling.js
CHANGED
|
@@ -75,7 +75,7 @@ const skolemCache = new Map();
|
|
|
75
75
|
const jsonPointerCache = new Map();
|
|
76
76
|
|
|
77
77
|
// Controls whether human-readable proof comments are printed.
|
|
78
|
-
let proofCommentsEnabled =
|
|
78
|
+
let proofCommentsEnabled = false;
|
|
79
79
|
|
|
80
80
|
// ----------------------------------------------------------------------------
|
|
81
81
|
// Deterministic time support
|
|
@@ -5558,7 +5558,6 @@ function localIsoDateTimeString(d) {
|
|
|
5558
5558
|
// ============================================================================
|
|
5559
5559
|
// CLI entry point
|
|
5560
5560
|
// ============================================================================
|
|
5561
|
-
|
|
5562
5561
|
function main() {
|
|
5563
5562
|
// Drop "node" and script name; keep only user-provided args
|
|
5564
5563
|
const argv = process.argv.slice(2);
|
|
@@ -5566,6 +5565,19 @@ function main() {
|
|
|
5566
5565
|
// --------------------------------------------------------------------------
|
|
5567
5566
|
// Global options
|
|
5568
5567
|
// --------------------------------------------------------------------------
|
|
5568
|
+
// --help / -h: print help and exit
|
|
5569
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
5570
|
+
console.log(
|
|
5571
|
+
'Usage: eyeling.js [options] <file.n3>\n' +
|
|
5572
|
+
'\n' +
|
|
5573
|
+
'Options:\n' +
|
|
5574
|
+
' -h, --help Show this help and exit.\n' +
|
|
5575
|
+
' -v, --version Print version and exit.\n' +
|
|
5576
|
+
' -p, --proof-comments Enable proof explanations.\n' +
|
|
5577
|
+
' -n, --no-proof-comments Disable proof explanations (default).\n',
|
|
5578
|
+
);
|
|
5579
|
+
process.exit(0);
|
|
5580
|
+
}
|
|
5569
5581
|
|
|
5570
5582
|
// --version / -v: print version and exit
|
|
5571
5583
|
if (argv.includes('--version') || argv.includes('-v')) {
|
|
@@ -5573,7 +5585,13 @@ function main() {
|
|
|
5573
5585
|
process.exit(0);
|
|
5574
5586
|
}
|
|
5575
5587
|
|
|
5576
|
-
// --
|
|
5588
|
+
// --proof-comments / -p: enable proof explanations
|
|
5589
|
+
if (argv.includes('--proof-comments') || argv.includes('-p')) {
|
|
5590
|
+
proofCommentsEnabled = true;
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5593
|
+
// --no-proof-comments / -n: disable proof explanations (default)
|
|
5594
|
+
// Keep this after --proof-comments so -n wins if both are present.
|
|
5577
5595
|
if (argv.includes('--no-proof-comments') || argv.includes('-n')) {
|
|
5578
5596
|
proofCommentsEnabled = false;
|
|
5579
5597
|
}
|
|
@@ -5582,9 +5600,16 @@ function main() {
|
|
|
5582
5600
|
// Positional args (the N3 file)
|
|
5583
5601
|
// --------------------------------------------------------------------------
|
|
5584
5602
|
const positional = argv.filter((a) => !a.startsWith('-'));
|
|
5585
|
-
|
|
5586
5603
|
if (positional.length !== 1) {
|
|
5587
|
-
console.error(
|
|
5604
|
+
console.error(
|
|
5605
|
+
'Usage: eyeling.js [options] <file.n3>\n' +
|
|
5606
|
+
'\n' +
|
|
5607
|
+
'Options:\n' +
|
|
5608
|
+
' -h, --help Show this help and exit.\n' +
|
|
5609
|
+
' -v, --version Print version and exit.\n' +
|
|
5610
|
+
' -p, --proof-comments Enable proof explanations.\n' +
|
|
5611
|
+
' -n, --no-proof-comments Disable proof explanations (default).\n',
|
|
5612
|
+
);
|
|
5588
5613
|
process.exit(1);
|
|
5589
5614
|
}
|
|
5590
5615
|
|
|
@@ -5603,12 +5628,12 @@ function main() {
|
|
|
5603
5628
|
const [prefixes, triples, frules, brules] = parser.parseDocument();
|
|
5604
5629
|
// console.log(JSON.stringify([prefixes, triples, frules, brules], null, 2));
|
|
5605
5630
|
|
|
5606
|
-
// Build internal ListTerm values from rdf:first/rdf:rest (+ rdf:nil)
|
|
5631
|
+
// Build internal ListTerm values from rdf:first/rdf:rest (+ rdf:nil)
|
|
5632
|
+
// input triples
|
|
5607
5633
|
materializeRdfLists(triples, frules, brules);
|
|
5608
5634
|
|
|
5609
5635
|
const facts = triples.filter((tr) => isGroundTriple(tr));
|
|
5610
5636
|
const derived = forwardChain(facts, frules, brules);
|
|
5611
|
-
|
|
5612
5637
|
const derivedTriples = derived.map((df) => df.fact);
|
|
5613
5638
|
const usedPrefixes = prefixes.prefixesUsedForOutput(derivedTriples);
|
|
5614
5639
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
+'use strict';
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const os = require('node:os');
|
|
@@ -13,15 +13,23 @@ function reason(opt = {}, n3_input = '') {
|
|
|
13
13
|
|
|
14
14
|
// allow passing an args array directly
|
|
15
15
|
if (Array.isArray(opt)) opt = { args: opt };
|
|
16
|
+
if (opt == null || typeof opt !== 'object') opt = {};
|
|
16
17
|
|
|
17
18
|
const args = [];
|
|
18
19
|
|
|
19
20
|
// default: proof comments OFF for API output (machine-friendly)
|
|
20
21
|
// set { proofComments: true } to keep them
|
|
22
|
+
const proofCommentsSpecified = typeof opt.proofComments === 'boolean' || typeof opt.noProofComments === 'boolean';
|
|
23
|
+
|
|
21
24
|
const proofComments =
|
|
22
25
|
typeof opt.proofComments === 'boolean' ? opt.proofComments : typeof opt.noProofComments === 'boolean' ? !opt.noProofComments : false;
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
// Only pass a flag when the caller explicitly asked.
|
|
28
|
+
// (CLI default is now: no proof comments.)
|
|
29
|
+
if (proofCommentsSpecified) {
|
|
30
|
+
if (proofComments) args.push('--proof-comments');
|
|
31
|
+
else args.push('--no-proof-comments');
|
|
32
|
+
}
|
|
25
33
|
|
|
26
34
|
if (Array.isArray(opt.args)) args.push(...opt.args);
|
|
27
35
|
|
|
@@ -34,10 +42,7 @@ function reason(opt = {}, n3_input = '') {
|
|
|
34
42
|
fs.writeFileSync(inputFile, n3_input, 'utf8');
|
|
35
43
|
|
|
36
44
|
const eyelingPath = path.join(__dirname, 'eyeling.js');
|
|
37
|
-
const res = cp.spawnSync(process.execPath, [eyelingPath, ...args, inputFile], {
|
|
38
|
-
encoding: 'utf8',
|
|
39
|
-
maxBuffer,
|
|
40
|
-
});
|
|
45
|
+
const res = cp.spawnSync(process.execPath, [eyelingPath, ...args, inputFile], { encoding: 'utf8', maxBuffer });
|
|
41
46
|
|
|
42
47
|
if (res.error) throw res.error;
|
|
43
48
|
if (res.status !== 0) {
|
|
@@ -47,6 +52,7 @@ function reason(opt = {}, n3_input = '') {
|
|
|
47
52
|
err.stderr = res.stderr;
|
|
48
53
|
throw err;
|
|
49
54
|
}
|
|
55
|
+
|
|
50
56
|
return res.stdout;
|
|
51
57
|
} finally {
|
|
52
58
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
@@ -54,5 +60,6 @@ function reason(opt = {}, n3_input = '') {
|
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
module.exports = { reason };
|
|
63
|
+
|
|
57
64
|
// small interop nicety for ESM default import
|
|
58
65
|
module.exports.default = module.exports;
|