reasoning: prevent unsupported comparison decomposition
This commit is contained in:
+23
-28
@@ -1387,6 +1387,12 @@ function describeObservationFocus(context, which) {
|
||||
return which === "first" ? "the first observation" : "the second observation";
|
||||
}
|
||||
|
||||
function parentSupportsComparisonDecomposition(parentText) {
|
||||
return /\b(compare|comparison|comparable|comparability|different timing|timing|measured|measurement|basis|scale|same period|timing or measurement basis|two observations)\b/.test(
|
||||
parentText,
|
||||
);
|
||||
}
|
||||
|
||||
function buildDecompositionTemplates(parentNode, graph, depth = 0) {
|
||||
const parentText = normaliseText(
|
||||
`${parentNode?.label || ""} ${parentNode?.description || ""}`,
|
||||
@@ -1468,7 +1474,7 @@ function buildDecompositionTemplates(parentNode, graph, depth = 0) {
|
||||
];
|
||||
}
|
||||
|
||||
if (/\btiming or measurement basis\b/i.test(parentNode.label)) {
|
||||
if (parentSupportsComparisonDecomposition(parentText)) {
|
||||
return [
|
||||
{
|
||||
label: "Whether the two observations reflect different timing",
|
||||
@@ -1481,38 +1487,27 @@ function buildDecompositionTemplates(parentNode, graph, depth = 0) {
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
label: "Whether the two observations reflect different timing",
|
||||
description: `Need to know whether the two observations reflect different timing, because that could help explain ${context.centralStatement}.`,
|
||||
},
|
||||
{
|
||||
label: "How the two observations were measured",
|
||||
description: `Need evidence about the measure used for each observation, because that could help explain ${context.centralStatement}.`,
|
||||
},
|
||||
{
|
||||
label: `Possible change mainly affecting ${firstFocus}`,
|
||||
description: `Need to know whether a possible change mainly affected ${firstFocus}, because that could help explain ${context.centralStatement}.`,
|
||||
},
|
||||
{
|
||||
label: `Possible change mainly affecting ${secondFocus}`,
|
||||
description: `Need to know whether a possible change mainly affected ${secondFocus}, because that could help explain ${context.centralStatement}.`,
|
||||
},
|
||||
depth === 0
|
||||
? {
|
||||
label: "Possible one-off event during the period",
|
||||
description: `Need to know whether a possible one-off event happened during the period, because that could help explain ${context.centralStatement}.`,
|
||||
}
|
||||
: {
|
||||
label: "Mix shift during the period",
|
||||
description: `Need to know whether the mix of cases, customers, or items shifted during the period, because that could help explain ${context.centralStatement}.`,
|
||||
},
|
||||
];
|
||||
return [];
|
||||
}
|
||||
|
||||
function buildCompositeUnknownChildren(parentNode, graph, depth = 0) {
|
||||
const templates = buildDecompositionTemplates(parentNode, graph, depth);
|
||||
|
||||
if (templates.length === 0) {
|
||||
return {
|
||||
accepted: false,
|
||||
childNodes: [],
|
||||
childEdges: [],
|
||||
childNodeIds: [],
|
||||
proposedChildCount: 0,
|
||||
acceptedChildCount: 0,
|
||||
rejectedChildren: [],
|
||||
childQualitySummary: [],
|
||||
reason:
|
||||
"Decomposition stopped because no meaning-preserving child family was justified for this parent.",
|
||||
};
|
||||
}
|
||||
|
||||
const labelToId = new Map(
|
||||
templates.map((template) => [
|
||||
template.label,
|
||||
|
||||
Reference in New Issue
Block a user