Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

W-C8: placeholder CJK/Hangul names in by-mention-hangul fixtures

garrytanb426df5ec77f
diff --git a/test/by-mention-hangul.test.ts b/test/by-mention-hangul.test.ts
index 4153bdeefc..14afc6283f 100644
--- a/test/by-mention-hangul.test.ts
+++ b/test/by-mention-hangul.test.ts
@@ -16,11 +16,11 @@ beforeAll(async () => {
['people/jiwon', '지원'],
['companies/jangin', '장인'],
['people/inha', '인하'],
- ['companies/samsung-card', '삼성카드'],
- ['companies/spaced', '삼성 카드'],
+ ['companies/example-card', '예시카드'],
+ ['companies/spaced', '예시 카드'],
['companies/longer', '지원 회사'],
['companies/alias', 'Example Company'],
- ['people/naval', '纳瓦尔'],
+ ['people/alice-example', '艾例丝'],
]) {
await engine.putPage(slug!, {
type: 'company', title: title!, compiled_truth: '', timeline: '', frontmatter: {},
@@ -64,10 +64,10 @@ describe('Hangul mention boundaries', () => {
});
test('preserves spaces explicitly present in a Hangul name', () => {
- expect(tokenizeTitle('삼성 카드')).toEqual(['삼', '성', '카', '드']);
- expect(mentions('삼성\t카드에서 일한다')).toEqual(['companies/spaced']);
- expect(mentions('삼성카드에서 일한다')).toEqual(['companies/samsung-card']);
- expect(mentions('삼성,카드')).toEqual([]);
+ expect(tokenizeTitle('예시 카드')).toEqual(['예', '시', '카', '드']);
+ expect(mentions('예시\t카드에서 일한다')).toEqual(['companies/spaced']);
+ expect(mentions('예시카드에서 일한다')).toEqual(['companies/example-card']);
+ expect(mentions('예시,카드')).toEqual([]);
});
test('rejecting the longest candidate still allows a valid shorter name', () => {
@@ -83,21 +83,21 @@ describe('Hangul mention boundaries', () => {
});
test('same-token own-source preference cannot override a spacing mismatch', () => {
- const entry = gazetteer.get('삼')!.find(e => e.slug === 'companies/spaced')!;
- const twin: Gazetteer = new Map([['삼', [
+ const entry = gazetteer.get('예')!.find(e => e.slug === 'companies/spaced')!;
+ const twin: Gazetteer = new Map([['예', [
{ ...entry, source_id: 'foreign' },
- { ...entry, source_id: 'default', matchText: '삼성카드' },
+ { ...entry, source_id: 'default', matchText: '예시카드' },
]]]);
- expect(findMentionedEntities('삼성 카드에서 일한다', twin, {
+ expect(findMentionedEntities('예시 카드에서 일한다', twin, {
...opts, allowCrossSource: true,
}).map(m => m.source_id)).toEqual(['foreign']);
- expect(findMentionedEntities('삼성 카드에서 일한다', twin, opts)).toEqual([]);
+ expect(findMentionedEntities('예시 카드에서 일한다', twin, opts)).toEqual([]);
});
test('resume identity includes spelling and invalidates the old matcher fingerprint', () => {
- const entry = gazetteer.get('삼')!.find(e => e.slug === 'companies/spaced')!;
- const spaced: Gazetteer = new Map([['삼', [entry]]]);
- const unspaced: Gazetteer = new Map([['삼', [{ ...entry, matchText: '삼성카드' }]]]);
+ const entry = gazetteer.get('예')!.find(e => e.slug === 'companies/spaced')!;
+ const spaced: Gazetteer = new Map([['예', [entry]]]);
+ const unspaced: Gazetteer = new Map([['예', [{ ...entry, matchText: '예시카드' }]]]);
expect(hashGazetteer(spaced)).not.toBe(hashGazetteer(unspaced));
const legacy = createHash('sha256').update(
`${entry.source_id}\0${entry.slug}\0${entry.title}\0${entry.tokens.join(' ')}`,
@@ -107,7 +107,7 @@ describe('Hangul mention boundaries', () => {
});
test('preserves Han substring matching and self/cross-source/code guards', () => {
- expect(mentions('我读了纳瓦尔的书')).toEqual(['people/naval']);
+ expect(mentions('我读了艾例丝的书')).toEqual(['people/alice-example']);
expect(mentions('```\n지원이 왔다\n```')).toEqual([]);
expect(findMentionedEntities('지원이 왔다', gazetteer, {
fromSlug: 'people/jiwon', fromSourceId: 'default',