归一:全角数字→半角、去千分位逗号、percent→%、小写。
(s: string)
| 65 | |
| 66 | /** 归一:全角数字→半角、去千分位逗号、percent→%、小写。 */ |
| 67 | function normNum(s: string): string { |
| 68 | return s |
| 69 | .replace(/[0-9]/g, (c) => "0123456789"["0123456789".indexOf(c)]) |
| 70 | .replace(/(\d),(?=\d{3}(\D|$))/g, "$1") |
| 71 | .replace(/percent/gi, "%") |
| 72 | .toLowerCase(); |
| 73 | } |
| 74 | |
| 75 | interface NumTokens { |
| 76 | strong: Set<string>; // 具体数字/日期/百分比/量级(不含裸年份) |