From 8bf37e21c5a4e907eeee6000214fef73101a28ee Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Sat, 16 Nov 2024 22:06:20 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20moraPattern=E3=82=92domain/japanese?= =?UTF-8?q?=E3=81=AB=E7=A7=BB=E5=8B=95=20(#2350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/japanese/index.ts | 15 +++++++++++++++ src/sing/domain.ts | 17 +---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/domain/japanese/index.ts b/src/domain/japanese/index.ts index e9a90bdfad..44c606e9f1 100644 --- a/src/domain/japanese/index.ts +++ b/src/domain/japanese/index.ts @@ -40,3 +40,18 @@ export const convertLongVowel = (text: string): string => { .replace(/(?<=[ん]ー*)ー/g, "ん") .replace(/(?<=[っ]ー*)ー/g, "っ"); }; + +// 参考:https://github.com/VOICEVOX/voicevox_core/blob/0848630d81ae3e917c6ff2038f0b15bbd4270702/crates/voicevox_core/src/user_dict/word.rs#L83-L90 +export const moraPattern = new RegExp( + "(?:" + + "[イ][ェ]|[ヴ][ャュョ]|[トド][ゥ]|[テデ][ィャュョ]|[デ][ェ]|[クグ][ヮ]|" + // rule_others + "[キシチニヒミリギジビピ][ェャュョ]|" + // rule_line_i + "[ツフヴ][ァ]|[ウスツフヴズ][ィ]|[ウツフヴ][ェォ]|" + // rule_line_u + "[ァ-ヴー]|" + // rule_one_mora + "[い][ぇ]|[ゃゅょ]|[とど][ぅ]|[てで][ぃゃゅょ]|[で][ぇ]|[くぐ][ゎ]|" + // rule_others + "[きしちにひみりぎじびぴ][ぇゃゅょ]|" + // rule_line_i + "[つふゔ][ぁ]|[うすつふゔず][ぃ]|[うつふゔ][ぇぉ]|" + // rule_line_u + "[ぁ-ゔー]" + // rule_one_mora + ")", + "g", +); diff --git a/src/sing/domain.ts b/src/sing/domain.ts index 95d12ab1e7..faf7230042 100644 --- a/src/sing/domain.ts +++ b/src/sing/domain.ts @@ -1,5 +1,5 @@ import { calculateHash } from "./utility"; -import { convertLongVowel } from "@/domain/japanese"; +import { convertLongVowel, moraPattern } from "@/domain/japanese"; import { Note, Phrase, @@ -534,21 +534,6 @@ export function applyPitchEdit( } } -// 参考:https://github.com/VOICEVOX/voicevox_core/blob/0848630d81ae3e917c6ff2038f0b15bbd4270702/crates/voicevox_core/src/user_dict/word.rs#L83-L90 -export const moraPattern = new RegExp( - "(?:" + - "[イ][ェ]|[ヴ][ャュョ]|[トド][ゥ]|[テデ][ィャュョ]|[デ][ェ]|[クグ][ヮ]|" + // rule_others - "[キシチニヒミリギジビピ][ェャュョ]|" + // rule_line_i - "[ツフヴ][ァ]|[ウスツフヴズ][ィ]|[ウツフヴ][ェォ]|" + // rule_line_u - "[ァ-ヴー]|" + // rule_one_mora - "[い][ぇ]|[ゃゅょ]|[とど][ぅ]|[てで][ぃゃゅょ]|[で][ぇ]|[くぐ][ゎ]|" + // rule_others - "[きしちにひみりぎじびぴ][ぇゃゅょ]|" + // rule_line_i - "[つふゔ][ぁ]|[うすつふゔず][ぃ]|[うつふゔ][ぇぉ]|" + // rule_line_u - "[ぁ-ゔー]" + // rule_one_mora - ")", - "g", -); - /** * 文字列をモーラと非モーラに分割する。長音は展開される。連続する非モーラはまとめる。 * 例:"カナー漢字" -> ["カ", "ナ", "ア", "漢字"]