From 25b367a1a1e0b2e686778f52a4cf2a10c21a53ca Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 19 Jun 2024 23:41:24 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86:=20`=5FPartOfSpeechDetail`?= =?UTF-8?q?=20=E3=82=92=20`dataclass`=20=E3=81=B8=E5=A4=89=E6=9B=B4=20(#13?= =?UTF-8?q?95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: `PartOfSpeechDetail` を `dataclass` へ変更 * refactor: コメントを集約 * add; dataclass の凍結を追加 --- voicevox_engine/user_dict/user_dict_word.py | 26 +++++++++------------ 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/voicevox_engine/user_dict/user_dict_word.py b/voicevox_engine/user_dict/user_dict_word.py index 301cd946c..629649b07 100644 --- a/voicevox_engine/user_dict/user_dict_word.py +++ b/voicevox_engine/user_dict/user_dict_word.py @@ -3,7 +3,6 @@ from dataclasses import dataclass import numpy as np -from pydantic import BaseModel, Field from voicevox_engine.user_dict.model import ( USER_DICT_MAX_PRIORITY, @@ -13,20 +12,17 @@ ) -class _PartOfSpeechDetail(BaseModel): - """ - 品詞ごとの情報 - """ - - part_of_speech: str = Field(title="品詞") - part_of_speech_detail_1: str = Field(title="品詞細分類1") - part_of_speech_detail_2: str = Field(title="品詞細分類2") - part_of_speech_detail_3: str = Field(title="品詞細分類3") - # context_idは辞書の左・右文脈IDのこと - # https://github.com/VOICEVOX/open_jtalk/blob/427cfd761b78efb6094bea3c5bb8c968f0d711ab/src/mecab-naist-jdic/_left-id.def # noqa - context_id: int = Field(title="文脈ID") - cost_candidates: list[int] = Field(title="コストのパーセンタイル") - accent_associative_rules: list[str] = Field(title="アクセント結合規則の一覧") +@dataclass(frozen=True) +class _PartOfSpeechDetail: + """品詞ごとの情報""" + + part_of_speech: str # 品詞 + part_of_speech_detail_1: str # 品詞細分類1 + part_of_speech_detail_2: str # 品詞細分類2 + part_of_speech_detail_3: str # 品詞細分類3 + context_id: int # 辞書の左・右文脈ID。https://github.com/VOICEVOX/open_jtalk/blob/427cfd761b78efb6094bea3c5bb8c968f0d711ab/src/mecab-naist-jdic/_left-id.def # noqa + cost_candidates: list[int] # コストのパーセンタイル + accent_associative_rules: list[str] # アクセント結合規則の一覧 _costs_proper_noun = [-988, 3488, 4768, 6048, 7328, 8609, 8734, 8859, 8984, 9110, 14176]