fix(reasoning): narrow decision audience question routing
This commit is contained in:
@@ -57,6 +57,31 @@ function collectResolvedContextValues(graph) {
|
||||
.filter((value) => typeof value === "string" && value.trim().length > 0);
|
||||
}
|
||||
|
||||
function hasAudienceIdentityQuestion(text) {
|
||||
const normalised = normaliseText(text);
|
||||
if (!normalised) return false;
|
||||
|
||||
return (
|
||||
/\bwho\s+(is|are)\s+(the\s+)?(customer|user|buyer|stakeholder|recipient|audience)\b/.test(
|
||||
normalised,
|
||||
) ||
|
||||
/\bwhich\s+(customer|user|buyer|stakeholder|recipient|audience|segment|segments)\b/.test(
|
||||
normalised,
|
||||
) ||
|
||||
/\b(target|intended)\s+(customer|user|buyer|stakeholder|recipient|audience|segment)\b/.test(
|
||||
normalised,
|
||||
) ||
|
||||
/\bidentify(ing)?\s+(the\s+)?(customer|user|buyer|stakeholder|recipient|audience|segment)\b/.test(
|
||||
normalised,
|
||||
) ||
|
||||
/\bwho\s+experiences\b/.test(normalised) ||
|
||||
/\bwho\s+(this|the decision|the product|the service)\s+is\s+for\b/.test(
|
||||
normalised,
|
||||
) ||
|
||||
/\bwho\s+would\s+(receive|use|benefit)\b/.test(normalised)
|
||||
);
|
||||
}
|
||||
|
||||
function extractMeaning(node) {
|
||||
const raw = `${node?.label || ""} ${node?.description || ""}`.trim();
|
||||
let meaning = stripTrailingPunctuation(
|
||||
@@ -64,12 +89,25 @@ function extractMeaning(node) {
|
||||
).trim();
|
||||
|
||||
const lowered = normaliseText(raw);
|
||||
if (
|
||||
/\b(customer|user|buyer|stakeholder|recipient|audience)\b/.test(lowered)
|
||||
) {
|
||||
if (hasAudienceIdentityQuestion(lowered)) {
|
||||
return "the relevant customer, user, or value recipient";
|
||||
}
|
||||
|
||||
const description = String(node?.description || "").trim();
|
||||
const strippedDescription = stripTrailingPunctuation(description)
|
||||
.replace(/^uncertainty regarding\s+/i, "")
|
||||
.replace(/^uncertainty about\s+/i, "")
|
||||
.trim();
|
||||
|
||||
if (
|
||||
/\b(status|likelihood|probability|chance|risk|uncertainty)\b/i.test(
|
||||
String(node?.label || ""),
|
||||
) &&
|
||||
/^whether\s+/i.test(strippedDescription)
|
||||
) {
|
||||
return sentenceCase(strippedDescription);
|
||||
}
|
||||
|
||||
meaning = meaning
|
||||
.replace(/^uncertainty regarding\s+/i, "")
|
||||
.replace(/^uncertainty about\s+/i, "")
|
||||
@@ -123,7 +161,9 @@ function sanitizeQuestionText(question) {
|
||||
* relocation realistic in this situation?".
|
||||
*/
|
||||
function isInterrogativeMeaning(meaning) {
|
||||
const trimmed = String(meaning || "").trim().toLowerCase();
|
||||
const trimmed = String(meaning || "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
if (!trimmed) return false;
|
||||
|
||||
// Wh-questions (direct or indirect): who/what/where/when/how ...
|
||||
@@ -1159,11 +1199,7 @@ function selectQuestionFamily({
|
||||
}
|
||||
|
||||
if (reasoningPattern === "decision") {
|
||||
if (
|
||||
/\b(audience|customer|user|buyer|stakeholder|recipient|who experiences)\b/.test(
|
||||
text,
|
||||
)
|
||||
) {
|
||||
if (hasAudienceIdentityQuestion(text)) {
|
||||
return { family: "decision_foundation", template: "decision_audience" };
|
||||
}
|
||||
if (
|
||||
@@ -1743,7 +1779,9 @@ function validateFormulatedQuestion(question, meaning) {
|
||||
}
|
||||
if (
|
||||
!overlappingWord &&
|
||||
!/\b(decision|evidence|constraint|customer|value|outcome)\b/i.test(trimmed)
|
||||
!/\b(decision|evidence|constraint|customer|user|buyer|stakeholder|recipient|audience|value|outcome|who experiences)\b/i.test(
|
||||
trimmed,
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user