From 9fce59e0f0a1849530e77739bf6b4010d41afef4 Mon Sep 17 00:00:00 2001 From: Peter Olson Date: Sun, 15 Dec 2019 17:41:33 +0600 Subject: [PATCH] =?UTF-8?q?traditionalize=20=E9=9D=A2=E9=BA=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/simplify.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/simplify.js b/src/simplify.js index 7c34b3d..83691d9 100644 --- a/src/simplify.js +++ b/src/simplify.js @@ -9,7 +9,7 @@ function simplify(text) { }).join(""); } -const specialChars = new Set(["只", "喂"]); +const specialChars = new Set(["只", "喂", "面"]); function traditionalize(text) { return segment(text).map((x, i, segments) => { @@ -34,6 +34,10 @@ function traditionalizeSpecialChar(char, beforeText, afterText) { after = nodejieba.tag(afterText.join(""))[0]; if (after && after.tag === "n") return "餵"; return "喂"; + case "面": + prev = nodejieba.tag(beforeText.join("")).slice(-1)[0]; + if (prev && prev.tag === "v") return "麵"; + return "面"; } return char in s2tDict ? s2tDict[char] : char; }