test: generalise question priority across decisions
This commit is contained in:
@@ -141,6 +141,9 @@ function toGerundPhrase(phrase) {
|
||||
|
||||
function detectStrategy({ node, graph, relatedNodes, combinedText, meaning }) {
|
||||
const text = normaliseText(combinedText);
|
||||
const nodeText = normaliseText(
|
||||
`${node?.label || ""} ${node?.description || ""}`,
|
||||
);
|
||||
const relatedText = normaliseText(
|
||||
relatedNodes
|
||||
.map((relatedNode) => `${relatedNode.label} ${relatedNode.description}`)
|
||||
@@ -160,19 +163,25 @@ function detectStrategy({ node, graph, relatedNodes, combinedText, meaning }) {
|
||||
`${text} ${relatedText} ${resolvedValues.join(" ")}`,
|
||||
) || Boolean(actionPhrase);
|
||||
|
||||
if (
|
||||
const hasConstraintLanguage =
|
||||
/\b(constraint|limit|budget|deadline|requirement|regulation|capacity)\b/.test(
|
||||
text,
|
||||
)
|
||||
) {
|
||||
return { strategy: "constraint", meaning, actionPhrase };
|
||||
}
|
||||
);
|
||||
const hasPrimaryConstraintLanguage =
|
||||
/\b(constraint|limit|budget|deadline|requirement|regulation|capacity)\b/.test(
|
||||
nodeText,
|
||||
);
|
||||
|
||||
if (/\b(customer|user|buyer|stakeholder|recipient|audience)\b/.test(text)) {
|
||||
return { strategy: "actor/customer", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (/\b(before|previous|baseline|prior|comparable state)\b/.test(text)) {
|
||||
const hasBaselineLanguage =
|
||||
/\b(before|previous|baseline|prior|comparable state)\b/.test(text);
|
||||
const hasPrimaryBaselineLanguage =
|
||||
/\b(before|previous|baseline|prior|comparable state)\b/.test(nodeText);
|
||||
|
||||
if (hasBaselineLanguage && hasPrimaryBaselineLanguage) {
|
||||
return { strategy: "baseline", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
@@ -182,6 +191,12 @@ function detectStrategy({ node, graph, relatedNodes, combinedText, meaning }) {
|
||||
|
||||
const hasDefinitionLanguage =
|
||||
/\b(define|definition|meaning|term|terminology)\b/.test(text);
|
||||
const hasPrimaryDefinitionLanguage =
|
||||
/\b(define|definition|meaning|term|terminology)\b/.test(nodeText);
|
||||
const hasCriteriaLanguage =
|
||||
/\b(success criteria|success threshold|threshold|decision criteria|criterion|justify|sufficient)\b/.test(
|
||||
nodeText,
|
||||
);
|
||||
const hasDecisionValueLanguage =
|
||||
decisionContext &&
|
||||
/\b(value|commercial value|commercial viability|viability|justify|sufficient|success|threshold|criterion)\b/.test(
|
||||
@@ -196,14 +211,30 @@ function detectStrategy({ node, graph, relatedNodes, combinedText, meaning }) {
|
||||
return { strategy: "measurement", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (/\b(define|definition|meaning|term|terminology)\b/.test(text)) {
|
||||
if (hasPrimaryDefinitionLanguage) {
|
||||
return { strategy: "definition", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (hasDecisionValueLanguage) {
|
||||
if (hasDecisionValueLanguage || hasCriteriaLanguage) {
|
||||
return { strategy: "decision criterion", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (hasConstraintLanguage && hasPrimaryConstraintLanguage) {
|
||||
return { strategy: "constraint", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (hasDefinitionLanguage) {
|
||||
return { strategy: "definition", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (hasBaselineLanguage) {
|
||||
return { strategy: "baseline", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (hasConstraintLanguage) {
|
||||
return { strategy: "constraint", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
if (/\b(evidence|proof|validate|validation|signal|demand)\b/.test(text)) {
|
||||
return { strategy: "evidence", meaning, actionPhrase };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user