At the moment DatasetWrapper.subjectsOf (and the other mwthods here) might return the same term multiple times in its result Iterable, though intuition would imply distinct values.
Consider this input:
<s> <p> <o1> .
<s> <p> <o2> .
subjectsOf("p") translates (conceptually) to the following:
for (const quad of dataset.match(undefined, p, undefined, undefined)) {
yield quad.subject
}
which matches both statements in the input, so it returns <s> twice.
Instead we should ensure that only unique terms are returned:
const seen = new Set<Term>
for (const quad of dataset.match(undefined, p, undefined, undefined)) {
if (seen.has(quad.subject) continue
seen.add(quad.subject)
yield quad.subject
}
At the moment
DatasetWrapper.subjectsOf(and the other mwthods here) might return the same term multiple times in its resultIterable, though intuition would imply distinct values.Consider this input:
subjectsOf("p")translates (conceptually) to the following:which matches both statements in the input, so it returns
<s>twice.Instead we should ensure that only unique terms are returned: