뉴스 답: 표 바깥 날짜 기준·제외 기사 메모를 코드로 제거(stripNewsMetaNotes) + 일본 기사 華火→花火 — '오늘 일본 뉴스'에 Haiku가 프롬프트 금지에도 '10월 23일(금) 기준 … 8건', '경제·환율 기사는 포함되지 않았습니다'를 붙이고, 東京湾大華火祭를 '도쿄만 대화화제'로 음차
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c028dbf8e
commit
2ae7aa74bd
5 files changed
+57
-2
No files matched your search
@@ -14,6 +14,7 @@ import {
|
||||
isFactualInfoRequest,
|
||||
isFactualThreadFollowUp,
|
||||
isNewsEntityFollowUp,
|
||||
stripNewsMetaNotes,
|
||||
confirmsUserGuessWithoutGrounding,
|
||||
looksLikeUnverifiedSpecClaim,
|
||||
isExemptFromVerification,
|
||||
@@ -2590,6 +2591,13 @@ async function handleChat(
|
||||
}
|
||||
finalText = appendDroppedSearchImages(finalText, allToolResults);
|
||||
finalText = appendGeneratedChartImages(finalText, allToolResults);
|
||||
if (allToolResults.some((r: any) => r?.name === 'news_search')) {
|
||||
const _stripped = stripNewsMetaNotes(finalText);
|
||||
if (_stripped !== finalText) {
|
||||
console.log('[v2] NEWS META STRIP: removed date/excluded-article notes around the news table.');
|
||||
finalText = _stripped;
|
||||
}
|
||||
}
|
||||
{
|
||||
// 날씨 도구가 전부 실패했는데 수치를 말하는 답은 지어낸 것 — EMPTY-GROUNDING 재프롬프트(1회) 뒤에도 남았다면 여기서 교체.
|
||||
const _fabricated = weatherFabricationReplacement(finalText, allToolResults);
|
||||
|
||||
@@ -213,6 +213,24 @@ export function isFactualThreadFollowUp(message: string, previousUserMessage: st
|
||||
return /[??]$/.test(m) || /(까|나요|니|냐|지|는가|은가|어때|얼마|몇|뭐|무엇|어디|언제|누구|왜|어떻게)\s*[??]?$/.test(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* 뉴스 표 바깥의 메타 문장 제거 — 프롬프트에 '날짜·신선도, 뺀 기사 얘기 금지'가 있어도 Haiku가
|
||||
* "검색 결과는 10월 23일(금) 기준 … 8건입니다", "참고로 … 경제·환율 기사는 포함되지 않았습니다"를
|
||||
* 붙였다(2026-10-24). 표 행은 건드리지 않고, 표 바깥 문장 중 날짜+기준 / 포함 안 됨·제외 표현이 있는
|
||||
* 문장만 뺀다. "기준금리" 같은 내용어는 날짜가 앞에 붙지 않으니 안 걸린다.
|
||||
*/
|
||||
export function stripNewsMetaNotes(answer: string): string {
|
||||
const text = String(answer || '');
|
||||
if (!/\|\s*제목\s*\|/.test(text)) return text;
|
||||
const META = /(\d{1,2}\s*일\s*(\([^)]*\))?\s*(오전|오후|\d{1,2}시)?\s*기준|포함되지\s*않|포함하지\s*않|빠졌|빠져\s*있|제외(했|되|된|하였))/;
|
||||
const out = text.split('\n').map(line => {
|
||||
if (!line.trim() || /^\s*\|/.test(line)) return line;
|
||||
const kept = line.split(/(?<=[.!?。])\s+/).filter(s => !META.test(s));
|
||||
return kept.length ? kept.join(' ') : null;
|
||||
}).filter((l): l is string => l !== null);
|
||||
return out.join('\n').replace(/\n{3,}/g, '\n\n').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 방금 뉴스 표에 나온 인물을 묻는 후속 질문("무라카미 류 누구지?").
|
||||
*
|
||||
|
||||
@@ -155,11 +155,15 @@ export function extractMetaDescription(html: string): string {
|
||||
return m ? m[1] : '';
|
||||
}
|
||||
|
||||
// 華火는 花火의 옛 표기(東京湾大華火祭 등) — 모델이 '대화화제'로 음차했다(2026-10-24). 흔한 표기로 바꿔 '불꽃'으로 읽히게.
|
||||
const JA_VARIANT_SPELLINGS: Array<[RegExp, string]> = [[/華火/g, '花火']];
|
||||
const normalizeVariants = (s: string) => JA_VARIANT_SPELLINGS.reduce((t, [re, to]) => t.replace(re, to), s);
|
||||
|
||||
export function formatHeadlines(items: readonly Headline[], limit = 12): string {
|
||||
return items.slice(0, limit)
|
||||
.map((h, i) => {
|
||||
const lines = [`[${i + 1}] ${h.title}`];
|
||||
if (h.summary) lines.push(` ${h.summary}`);
|
||||
const lines = [`[${i + 1}] ${normalizeVariants(h.title)}`];
|
||||
if (h.summary) lines.push(` ${normalizeVariants(h.summary)}`);
|
||||
lines.push(` ${h.link}`, ` Source: ${h.source}`);
|
||||
return lines.join('\n');
|
||||
})
|
||||
|
||||
@@ -17,6 +17,7 @@ import { test, describe } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
isNewsEntityFollowUp,
|
||||
stripNewsMetaNotes,
|
||||
looksLikeUnverifiedSpecClaim,
|
||||
isExemptFromVerification,
|
||||
isFactualInfoRequest,
|
||||
@@ -571,3 +572,19 @@ describe('isNewsEntityFollowUp', () => {
|
||||
assert.equal(isNewsEntityFollowUp('무라카미 류 작품 뭐 있어?', newsTable), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('stripNewsMetaNotes', () => {
|
||||
const table = '| 제목 | 요약 | 출처 |\n|---|---|---|\n| 프랑스 시위에 경찰 7만 명 | 24일 집회에 동원. | 로이터 |';
|
||||
test('[2026-10-24] drops the date-basis and excluded-article sentences, keeps the rest', () => {
|
||||
const ans = `오늘 일본 뉴스입니다. 검색 결과는 10월 23일(금) 기준 주요 매체 1면 톱기사 8건입니다.\n\n${table}\n\n참고로 이 결과는 1면 톱기사 목록이라 경제·환율 기사는 포함되지 않았습니다.`;
|
||||
assert.equal(stripNewsMetaNotes(ans), `오늘 일본 뉴스입니다.\n\n${table}`);
|
||||
});
|
||||
test('content words like 기준금리 survive', () => {
|
||||
const ans = `한국은행 기준금리 동결 기사가 많습니다.\n\n${table}`;
|
||||
assert.equal(stripNewsMetaNotes(ans), ans);
|
||||
});
|
||||
test('answers without a news table are untouched', () => {
|
||||
const ans = '10월 23일 기준 환율은 확인되지 않았습니다. 일부 기사는 제외했습니다.';
|
||||
assert.equal(stripNewsMetaNotes(ans), ans);
|
||||
});
|
||||
});
|
||||
@@ -150,3 +150,11 @@ describe('extractMetaDescription', () => {
|
||||
assert.equal(extractMetaDescription('<title>x</title>'), '');
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatHeadlines variant spellings', () => {
|
||||
test('[2026-10-24] 華火 → 花火 so the model reads it as fireworks', () => {
|
||||
const out = formatHeadlines([{ title: '東京湾大華火祭 11年ぶり', link: 'https://x', source: 'yahoo.co.jp', summary: '大華火祭が24日開催' }]);
|
||||
assert.ok(out.includes('東京湾大花火祭') && out.includes('大花火祭が'));
|
||||
assert.ok(!out.includes('華火'));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user