From 12ea369a60fcb6588ca030e364e5f3c06d01bbc6 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 21 Sep 2026 14:14:40 +0800 Subject: [PATCH] Update micFieldMapping.js via upload script - 2026-09-21 14:14:29 --- micFieldMapping.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/micFieldMapping.js b/micFieldMapping.js index e315ce5..85e090d 100644 --- a/micFieldMapping.js +++ b/micFieldMapping.js @@ -21,12 +21,29 @@ const SYMBOL_REPLACEMENTS = [ [/\u201C|\u201D/g, '"'], ]; +// 电池/电源规格里常见的中文量词——这些是实际踩过的坑(比如"16/20节"这种电池 +// 节数写法被MIC拒收),先只覆盖确认遇到过的几个,不是穷举翻译表。新遇到别的 +// 中文量词报错,把字符发我,这里加一行就行,不要自己瞎猜翻译。 +const UNIT_WORD_REPLACEMENTS = [ + [/节/g, ' Cells'], // 电池节数,如"16/20节" -> "16/20 Cells" + [/个/g, ' pcs'], + [/只/g, ' pcs'], + [/组/g, ' Set'], + [/台/g, ' Unit'], + [/根/g, ' pcs'], + [/套/g, ' Set'], +]; + function sanitizeValue(raw) { if (raw === null || raw === undefined) return ''; let s = String(raw).trim(); for (const [pattern, replacement] of SYMBOL_REPLACEMENTS) { s = s.replace(pattern, replacement); } + for (const [pattern, replacement] of UNIT_WORD_REPLACEMENTS) { + s = s.replace(pattern, replacement); + } + s = s.replace(/\s+/g, ' ').trim(); // 替换量词时前面加了空格,防止连续空格 return s; }