fix(schedule): parse ASR times with spaces around colons for ITL routing
Memind CI / Test, build, and release guards (push) Successful in 4m15s
Memind CI / Test, build, and release guards (push) Successful in 4m15s
Voice/wechat ASR often emits forms like "17 :08", which bypassed timed_reminder classification and fell through to agent_schedule + schedule-guard false failures. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+15
-3
@@ -12,6 +12,16 @@ function normalizeText(text) {
|
||||
.trim();
|
||||
}
|
||||
|
||||
/** ASR/wechat often inserts spaces around colons, e.g. "17 :08". */
|
||||
function normalizeLooseTimeText(text) {
|
||||
return String(text ?? '')
|
||||
.replace(
|
||||
/([0-9]{1,2}|[零一二两三四五六七八九十]{1,3})\s*([::])\s*/gu,
|
||||
'$1$2',
|
||||
)
|
||||
.replace(/([::])\s*([0-9]{1,2})/gu, '$1$2');
|
||||
}
|
||||
|
||||
function pad2(value) {
|
||||
return String(value).padStart(2, '0');
|
||||
}
|
||||
@@ -44,7 +54,8 @@ function chineseHourToNumber(value) {
|
||||
}
|
||||
|
||||
export function parseHourMinute(text) {
|
||||
const match = text.match(
|
||||
const normalized = normalizeLooseTimeText(text);
|
||||
const match = normalized.match(
|
||||
/(?:今天|明天|后天|今晚|明晚)?(?:早上|上午|清晨|每天(?:早上|上午)?)?(早上|上午|清晨|中午|下午|傍晚|晚上|凌晨)?([0-9]{1,2}|[零一二两三四五六七八九十]{1,3})(?:点|:|:)(半|[0-9]{1,2}分?)?/,
|
||||
);
|
||||
if (!match) return null;
|
||||
@@ -66,7 +77,8 @@ export function parseHourMinute(text) {
|
||||
}
|
||||
|
||||
function countTimeExpressions(text) {
|
||||
const matches = String(text ?? '').match(
|
||||
const normalized = normalizeLooseTimeText(text);
|
||||
const matches = normalized.match(
|
||||
/[0-9零一二两三四五六七八九十]{1,3}(?:点|:|:)(?:半|[0-9]{1,2}(?:分(?!开)|(?![0-9]))?)?/gu,
|
||||
);
|
||||
return matches?.length ?? 0;
|
||||
@@ -93,7 +105,7 @@ function extractTimedReminderTitle(text) {
|
||||
}
|
||||
|
||||
function cleanupTimedReminderTitleFragment(text) {
|
||||
let title = String(text ?? '').trim();
|
||||
let title = normalizeLooseTimeText(String(text ?? '').trim());
|
||||
title = title
|
||||
.replace(/^(?:帮我|请|麻烦)?(?:设置|设|创建|添加)(?:一个|个)?提醒[,,、::\s]*/u, '')
|
||||
.replace(/^(?:帮我|请)?(?:设置|设)(?:一个|个)?(?:待办|代办|带办|代拜)[,,、::\s]*/u, '');
|
||||
|
||||
Reference in New Issue
Block a user