n3 2.13.10 → 2.13.12
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 +2 -0
- package/browser/n3.esm.min.js +2 -2
- package/browser/n3.min.js +2 -2
- package/lib/N3DataFactory.js +2 -2
- package/lib/N3Reasoner.js +11 -6
- package/package.json +1 -1
- package/src/N3DataFactory.js +2 -2
- package/src/N3Reasoner.js +13 -8
package/lib/N3DataFactory.js
CHANGED
|
@@ -137,10 +137,10 @@ class Literal extends Term {
|
|
|
137
137
|
|
|
138
138
|
// ### The direction of this literal
|
|
139
139
|
get direction() {
|
|
140
|
-
// Find the last double dash after the closing quote (e.g., '"abc"@en-us--ltr')
|
|
140
|
+
// Find the last double dash after the closing quote and language tag (e.g., '"abc"@en-us--ltr')
|
|
141
141
|
const id = this.id;
|
|
142
142
|
const endPos = id.lastIndexOf('"');
|
|
143
|
-
const dirPos = id.lastIndexOf('--');
|
|
143
|
+
const dirPos = id[endPos + 1] === '@' ? id.lastIndexOf('--') : -1;
|
|
144
144
|
return dirPos > endPos && dirPos + 2 < id.length ? id.substr(dirPos + 2).toLowerCase() : '';
|
|
145
145
|
}
|
|
146
146
|
|
package/lib/N3Reasoner.js
CHANGED
|
@@ -105,8 +105,10 @@ class N3Reasoner {
|
|
|
105
105
|
}
|
|
106
106
|
val2.value = null;
|
|
107
107
|
}
|
|
108
|
-
//
|
|
109
|
-
else if (
|
|
108
|
+
// A bound leaf only matches if the quad exists
|
|
109
|
+
else if (value in index2) {
|
|
110
|
+
if (last) this._emit(rule, content, cb);else this._evaluatePremise(rule, content, cb, i + 1);
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
_evaluateRules(rules, content, cb) {
|
|
112
114
|
for (let i = 0; i < rules.length; i++) {
|
|
@@ -141,10 +143,13 @@ class N3Reasoner {
|
|
|
141
143
|
if (!v2) rule.basePremise.predicate.value = predicate;
|
|
142
144
|
const v3 = rule.basePremise.object.value;
|
|
143
145
|
if (!v3) rule.basePremise.object.value = object;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
|
|
147
|
+
// A repeated variable or a constant in the triggering premise must match the derived quad
|
|
148
|
+
const {
|
|
149
|
+
basePremise
|
|
150
|
+
} = rule;
|
|
151
|
+
if (basePremise.subject.value === subject && basePremise.predicate.value === predicate && basePremise.object.value === object) {
|
|
152
|
+
if (rule.premise.length === 0) addConclusions(rule.conclusion);else this._evaluatePremise(rule, content, addRule);
|
|
148
153
|
}
|
|
149
154
|
if (!v1) rule.basePremise.subject.value = null;
|
|
150
155
|
if (!v2) rule.basePremise.predicate.value = null;
|
package/package.json
CHANGED
package/src/N3DataFactory.js
CHANGED
|
@@ -125,10 +125,10 @@ export class Literal extends Term {
|
|
|
125
125
|
|
|
126
126
|
// ### The direction of this literal
|
|
127
127
|
get direction() {
|
|
128
|
-
// Find the last double dash after the closing quote (e.g., '"abc"@en-us--ltr')
|
|
128
|
+
// Find the last double dash after the closing quote and language tag (e.g., '"abc"@en-us--ltr')
|
|
129
129
|
const id = this.id;
|
|
130
130
|
const endPos = id.lastIndexOf('"');
|
|
131
|
-
const dirPos = id.lastIndexOf('--');
|
|
131
|
+
const dirPos = id[endPos + 1] === '@' ? id.lastIndexOf('--') : -1;
|
|
132
132
|
return dirPos > endPos && dirPos + 2 < id.length ? id.substr(dirPos + 2).toLowerCase() : '';
|
|
133
133
|
}
|
|
134
134
|
|
package/src/N3Reasoner.js
CHANGED
|
@@ -100,9 +100,11 @@ export default class N3Reasoner {
|
|
|
100
100
|
}
|
|
101
101
|
val2.value = null;
|
|
102
102
|
}
|
|
103
|
-
//
|
|
104
|
-
else if (
|
|
105
|
-
|
|
103
|
+
// A bound leaf only matches if the quad exists
|
|
104
|
+
else if (value in index2) {
|
|
105
|
+
if (last) this._emit(rule, content, cb);
|
|
106
|
+
else this._evaluatePremise(rule, content, cb, i + 1);
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
_evaluateRules(rules, content, cb) {
|
|
@@ -143,11 +145,14 @@ export default class N3Reasoner {
|
|
|
143
145
|
const v3 = rule.basePremise.object.value;
|
|
144
146
|
if (!v3) rule.basePremise.object.value = object;
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
// A repeated variable or a constant in the triggering premise must match the derived quad
|
|
149
|
+
const { basePremise } = rule;
|
|
150
|
+
if (basePremise.subject.value === subject && basePremise.predicate.value === predicate &&
|
|
151
|
+
basePremise.object.value === object) {
|
|
152
|
+
if (rule.premise.length === 0)
|
|
153
|
+
addConclusions(rule.conclusion);
|
|
154
|
+
else
|
|
155
|
+
this._evaluatePremise(rule, content, addRule);
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
if (!v1) rule.basePremise.subject.value = null;
|