This is a single premise of the form { subject, predicate, object },
which we can use to instantiate the rule using the new data that was emitted
basePremise: p,
});
}
r2.variables.forEach(v => { v.value = null; });
}
}
}
}
for (const rule of rules) {
const set = new Set();
rule.premise = rule.premise.map(p => getIndex(p, set));
}
const graphs = this._store._getGraphs();
for (const graphId in graphs) {
this._reasonGraphNaive(rules, graphs[graphId]);
}
this._store._size = null;
}
}
function getIndex({ subject, predicate, object }, set) {
const s = subject.value || set.has(subject) || (set.add(subject), false);
const p = predicate.value || set.has(predicate) || (set.add(predicate), false);
const o = object.value || set.has(object) || (set.add(object), false);
return (!s && p) ? { content: 'predicates', value: [predicate, object, subject] } :
o ? { content: 'objects', value: [object, subject, predicate] } :
{ content: 'subjects', value: [subject, predicate, object] };
}
function termEq(t1, t2) {
if (t1.value === null) {
t1.value = t2.value;
}
return t1.value === t2.value;
}