eyeling 1.13.1 → 1.13.3
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/examples/reifies.n3 +1 -2
- package/examples/triple-term.n3 +2 -2
- package/package.json +1 -1
- package/test/api.test.js +28 -0
- package/tools/n3gen.js +15 -4
package/examples/reifies.n3
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
2
1
|
@prefix : <http://www.example.org/> .
|
|
3
2
|
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
4
3
|
|
|
5
|
-
_:b
|
|
4
|
+
_:b log:nameOf { :Socrates a :Human . } .
|
|
6
5
|
_:b :is true .
|
|
7
6
|
:employee38 :familyName "Smith" .
|
|
8
7
|
_:id log:nameOf { :employee38 :jobTitle "Assistant Designer" . } .
|
package/examples/triple-term.n3
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@prefix : <http://www.example.org/> .
|
|
2
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
3
2
|
@prefix skolem: <https://eyereasoner.github.io/.well-known/genid/f327f7b5-4499-5c8b-9520-eab7551cbf00#> .
|
|
3
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
4
4
|
|
|
5
5
|
skolem:e38 :familyName "Smith" .
|
|
6
|
-
_:anno
|
|
6
|
+
_:anno log:nameOf { skolem:e38 :jobTitle "Designer" . } .
|
|
7
7
|
_:anno :accordingTo _:e22 .
|
package/package.json
CHANGED
package/test/api.test.js
CHANGED
|
@@ -984,6 +984,34 @@ ex:a p:trig ex:b.
|
|
|
984
984
|
/:result\s+:query3\s+\(:path1\s+1\s+:b\)\s*\./,
|
|
985
985
|
],
|
|
986
986
|
},
|
|
987
|
+
|
|
988
|
+
{
|
|
989
|
+
name: '57 issue #9: backward cycle with extra type guard should still derive label',
|
|
990
|
+
opt: { proofComments: false },
|
|
991
|
+
input: `@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
992
|
+
@prefix ex: <http://example.org/ns#> .
|
|
993
|
+
|
|
994
|
+
ex:w a ex:Woman .
|
|
995
|
+
|
|
996
|
+
{
|
|
997
|
+
?s a ex:Woman .
|
|
998
|
+
?s ex:label ?label .
|
|
999
|
+
} => {
|
|
1000
|
+
?s rdfs:label ?label .
|
|
1001
|
+
} .
|
|
1002
|
+
|
|
1003
|
+
{ ?s a ex:Human } <= { ?s a ex:Woman } .
|
|
1004
|
+
{ ?s a ex:Animal } <= { ?s a ex:Human } .
|
|
1005
|
+
|
|
1006
|
+
{ ?s ex:label "human being" } <= {
|
|
1007
|
+
?s a ex:Human .
|
|
1008
|
+
?s a ex:Animal .
|
|
1009
|
+
} .
|
|
1010
|
+
`,
|
|
1011
|
+
expect: [
|
|
1012
|
+
/(?:ex:w|<http:\/\/example\.org\/ns#w>)\s+(?:rdfs:label|<http:\/\/www\.w3\.org\/2000\/01\/rdf-schema#label>)\s+"human being"\s*\./,
|
|
1013
|
+
],
|
|
1014
|
+
},
|
|
987
1015
|
];
|
|
988
1016
|
|
|
989
1017
|
let passed = 0;
|
package/tools/n3gen.js
CHANGED
|
@@ -1032,7 +1032,7 @@ class TurtleParser {
|
|
|
1032
1032
|
if (typ === 'Var') return new Var(val || '');
|
|
1033
1033
|
if (typ === 'LParen') return this.parseList();
|
|
1034
1034
|
if (typ === 'LBracket') return this.parseBlank();
|
|
1035
|
-
if (typ === 'LBrace')
|
|
1035
|
+
if (typ === 'LBrace') throw new Error('N3 graph terms { ... } are not supported in Turtle/TriG input');
|
|
1036
1036
|
if (typ === 'StarOpen') return this.parseStarTerm();
|
|
1037
1037
|
|
|
1038
1038
|
throw new Error(`Unexpected term token: ${tok.toString()}`);
|
|
@@ -1239,7 +1239,18 @@ class TurtleParser {
|
|
|
1239
1239
|
const o = invert ? subject : obj;
|
|
1240
1240
|
|
|
1241
1241
|
// asserted triple
|
|
1242
|
-
|
|
1242
|
+
// Special-case RDF 1.2 explicit triple reification:
|
|
1243
|
+
// _:r rdf:reifies <<( s p o )>> .
|
|
1244
|
+
// Emit as:
|
|
1245
|
+
// _:r log:nameOf { s p o . } .
|
|
1246
|
+
// This matches the mapping we already use for reifiedTriple sugar and annotations.
|
|
1247
|
+
let assertedVerb = verb;
|
|
1248
|
+
let assertedObj = o;
|
|
1249
|
+
if (!invert && verb instanceof Iri && verb.value === RDF_NS + 'reifies' && obj instanceof GraphTerm) {
|
|
1250
|
+
assertedVerb = internIri(log.nameOf);
|
|
1251
|
+
assertedObj = obj;
|
|
1252
|
+
}
|
|
1253
|
+
out.push(new Triple(s, assertedVerb, assertedObj));
|
|
1243
1254
|
|
|
1244
1255
|
// optional reifier and/or annotation blocks
|
|
1245
1256
|
let reifier = null;
|
|
@@ -1257,7 +1268,7 @@ class TurtleParser {
|
|
|
1257
1268
|
}
|
|
1258
1269
|
|
|
1259
1270
|
if (reifier) {
|
|
1260
|
-
const tripleTerm = new GraphTerm([new Triple(s,
|
|
1271
|
+
const tripleTerm = new GraphTerm([new Triple(s, assertedVerb, assertedObj)]);
|
|
1261
1272
|
this.emitReifies(reifier, tripleTerm);
|
|
1262
1273
|
if (this.pendingTriples.length) {
|
|
1263
1274
|
out.push(...this.pendingTriples);
|
|
@@ -2043,7 +2054,7 @@ function writeN3LogNameOf({ datasetQuads, prefixes }) {
|
|
|
2043
2054
|
}
|
|
2044
2055
|
|
|
2045
2056
|
// ---------------------------------------------------------------------------
|
|
2046
|
-
//
|
|
2057
|
+
// Parsing + N3 output (Turtle/TriG -> N3)
|
|
2047
2058
|
// ---------------------------------------------------------------------------
|
|
2048
2059
|
|
|
2049
2060
|
function parseTriG(text) {
|