From 68405c9d9ee6061fdcd32aa1d5e45fa2acf89df0 Mon Sep 17 00:00:00 2001 From: DGCK81LNN <54282183+DGCK81LNN@users.noreply.github.com> Date: Mon, 8 Jan 2024 10:05:40 +0800 Subject: [PATCH] test: add test for x2h reduplication simplification @@__LNN_NO_BUILD__@@ --- package/test/base_transcribers.spec.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/package/test/base_transcribers.spec.ts b/package/test/base_transcribers.spec.ts index c54ff4b..0ae87ff 100644 --- a/package/test/base_transcribers.spec.ts +++ b/package/test/base_transcribers.spec.ts @@ -304,6 +304,31 @@ describe("base_transcribers", function () { ]) }) + it('obeys the "same-hanzi rule" for reduplicates', function () { + const t = new AlphaToHanziTranscriber({ + dict: [ + { h: "用", x: "y3" }, + { h: "心", x: "53" }, + { h: "蕊", x: "y353" }, + ], + }) + expect(t.transcribe("y353y353")).toEqual([ + [ + OW({ + content: [OW({ h: "蕊", x: "y353" }), OW({ h: "蕊", x: "y353" })], + }), + OW({ + content: [ + OW({ h: "用", x: "y3" }), + OW({ h: "心", x: "53" }), + OW({ h: "用", x: "y3" }), + OW({ h: "心", x: "53" }), + ], + }), + ], + ]) + }) + it("supports explicit separators", function () { const t = new AlphaToHanziTranscriber({ dict: [