If a relation has multiple definitions

We are filtering them from all relations
|
relations |
|
.flatMap((r) => { |
|
const queries = []; |
|
if (r.source === nodeType || r.source === "*") { |
|
queries.push({ |
|
r, |
|
complement: false, |
|
}); |
|
} |
|
if (r.destination === nodeType || r.destination === "*") { |
|
queries.push({ |
|
r, |
|
complement: true, |
|
}); |
|
} |
|
return queries; |
But in the datalog translator we are doing this again when we build the query
|
const filteredRelations = discourseRelations |
|
.map((r) => |
|
(r.label === label || ANY_RELATION_REGEX.test(label)) && |
|
doesDiscourseRelationMatchCondition(r, { source, target }) |
|
? { ...r, forward: true } |
|
: doesDiscourseRelationMatchCondition( |
|
{ source: r.destination, destination: r.source }, |
|
{ source, target } |
|
) && |
|
(r.complement === label || ANY_RELATION_REGEX.test(label)) |
|
? { ...r, forward: false } |
|
: undefined |
|
) |
|
.filter( |
|
( |
|
r |
|
): r is ReturnType<typeof getDiscourseRelations>[number] & { |
|
forward: boolean; |
|
} => !!r |
|
); |
|
if (!filteredRelations.length) return []; |
|
const andParts = filteredRelations.map( |
Resulting in multiple duplicate queries.
If a
relationhas multiple definitionsWe are filtering them from all
relationsquery-builder/src/utils/getDiscourseContextResults.ts
Lines 42 to 57 in 66caa79
But in the datalog translator we are doing this again when we build the query
query-builder/src/utils/registerDiscourseDatalogTranslators.ts
Lines 224 to 245 in 66caa79
Resulting in multiple duplicate queries.