eyeling 1.6.9 → 1.6.10
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/eyeling.js +55 -0
- package/package.json +1 -1
package/eyeling.js
CHANGED
|
@@ -4065,6 +4065,61 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
4065
4065
|
return [{ ...subst }];
|
|
4066
4066
|
}
|
|
4067
4067
|
|
|
4068
|
+
// log:dtlit
|
|
4069
|
+
// Schema: ( $s.1? $s.2? )? log:dtlit $o?
|
|
4070
|
+
// true iff $o is a datatyped literal with string value $s.1 and datatype IRI $s.2
|
|
4071
|
+
if (g.p instanceof Iri && g.p.value === LOG_NS + 'dtlit') {
|
|
4072
|
+
// Fully unbound (both arguments '?'-mode): treat as satisfiable, succeed once.
|
|
4073
|
+
// Required by notation3tests "success-fullUnbound-*".
|
|
4074
|
+
if (g.s instanceof Var && g.o instanceof Var) return [{ ...subst }];
|
|
4075
|
+
|
|
4076
|
+
const results = [];
|
|
4077
|
+
|
|
4078
|
+
// Direction 1: object literal -> subject list (string, datatype)
|
|
4079
|
+
if (g.o instanceof Literal) {
|
|
4080
|
+
const [oLex, oDt0] = literalParts(g.o.value);
|
|
4081
|
+
let oDt = oDt0;
|
|
4082
|
+
|
|
4083
|
+
// literalParts() strips @lang into the lexical part and leaves dt null,
|
|
4084
|
+
// but RDF 1.1 language-tagged strings have datatype rdf:langString.
|
|
4085
|
+
if (oDt === null) {
|
|
4086
|
+
if (literalHasLangTag(g.o.value)) oDt = RDF_NS + 'langString';
|
|
4087
|
+
else if (isPlainStringLiteralValue(g.o.value)) oDt = XSD_NS + 'string';
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
if (oDt !== null) {
|
|
4091
|
+
const strLit = isQuotedLexical(oLex) ? new Literal(oLex) : makeStringLiteral(String(oLex));
|
|
4092
|
+
const subjList = new ListTerm([strLit, new Iri(oDt)]);
|
|
4093
|
+
const s2 = unifyTerm(goal.s, subjList, subst);
|
|
4094
|
+
if (s2 !== null) results.push(s2);
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
// Direction 2: subject list -> object literal
|
|
4099
|
+
if (g.s instanceof ListTerm && g.s.elems.length === 2) {
|
|
4100
|
+
const a = g.s.elems[0];
|
|
4101
|
+
const b = g.s.elems[1];
|
|
4102
|
+
|
|
4103
|
+
if (a instanceof Literal && b instanceof Iri) {
|
|
4104
|
+
const [sLex, sDt0] = literalParts(a.value);
|
|
4105
|
+
|
|
4106
|
+
// $s.1 must be xsd:string (plain or ^^xsd:string), not language-tagged.
|
|
4107
|
+
const okString =
|
|
4108
|
+
(sDt0 === null && isPlainStringLiteralValue(a.value)) || sDt0 === XSD_NS + 'string';
|
|
4109
|
+
if (okString) {
|
|
4110
|
+
const dtIri = b.value;
|
|
4111
|
+
// For xsd:string, prefer the plain string literal form.
|
|
4112
|
+
const outLit =
|
|
4113
|
+
dtIri === XSD_NS + 'string' ? new Literal(sLex) : new Literal(`${sLex}^^<${dtIri}>`);
|
|
4114
|
+
const s2 = unifyTerm(goal.o, outLit, subst);
|
|
4115
|
+
if (s2 !== null) results.push(s2);
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
return results;
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4068
4123
|
// log:implies — expose internal forward rules as data
|
|
4069
4124
|
if (g.p instanceof Iri && g.p.value === LOG_NS + 'implies') {
|
|
4070
4125
|
const allFw = backRules.__allForwardRules || [];
|