Update micFieldMapping.js via upload script - 2026-09-21 14:14:29
This commit is contained in:
parent
cb3ec0d378
commit
12ea369a60
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue