From 55be96d0b75b514b6b724c042c55761e0a547463 Mon Sep 17 00:00:00 2001 From: Cashew Date: Sun, 13 Oct 2024 15:57:43 +0900 Subject: [PATCH 1/2] revert change --- ext/js/language/zh/chinese.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/js/language/zh/chinese.js b/ext/js/language/zh/chinese.js index 3da34403b0..8c5dd206fe 100644 --- a/ext/js/language/zh/chinese.js +++ b/ext/js/language/zh/chinese.js @@ -71,5 +71,5 @@ export function isCodePointChinese(codePoint) { /** @type {import('language').ReadingNormalizer} */ export function normalizePinyin(str) { - return str.normalize('NFC').toLowerCase().replace(/(?<=\w)'(?=\w)/g, "\\'"); + return str.normalize('NFC').toLowerCase().replace(/[\s・:]|\/\//g, ''); } From f3e21b2019a4aedb3b164a0ff6f4837efe46ab54 Mon Sep 17 00:00:00 2001 From: Cashew Date: Sun, 13 Oct 2024 16:00:23 +0900 Subject: [PATCH 2/2] readd separators, escape quote --- ext/js/language/zh/chinese.js | 2 +- test/language/chinese-reading-normalizer.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/js/language/zh/chinese.js b/ext/js/language/zh/chinese.js index 8c5dd206fe..ca89de1ec9 100644 --- a/ext/js/language/zh/chinese.js +++ b/ext/js/language/zh/chinese.js @@ -71,5 +71,5 @@ export function isCodePointChinese(codePoint) { /** @type {import('language').ReadingNormalizer} */ export function normalizePinyin(str) { - return str.normalize('NFC').toLowerCase().replace(/[\s・:]|\/\//g, ''); + return str.normalize('NFC').toLowerCase().replace(/[\s・:'’-]|\/\//g, ''); } diff --git a/test/language/chinese-reading-normalizer.test.js b/test/language/chinese-reading-normalizer.test.js index 166d1746a3..97d4fca27b 100644 --- a/test/language/chinese-reading-normalizer.test.js +++ b/test/language/chinese-reading-normalizer.test.js @@ -26,7 +26,7 @@ const tests = [ ['fān・yì', 'fānyì'], ['fān//yì', 'fānyì'], ['fān’yì', 'fānyì'], - ['fān'yì', 'fānyì'], + ['fān\'yì', 'fānyì'], ['fān-yì', 'fānyì'], ];