From 155b637a34b6df3b03f5b17960c783eadea3b74b Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 12 Jun 2024 01:45:17 +0000 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20`PartOfSpeechDetail`=20?= =?UTF-8?q?=E3=82=92=20`dataclass`=20=E3=81=B8=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- voicevox_engine/user_dict/user_dict_word.py | 22 ++++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/voicevox_engine/user_dict/user_dict_word.py b/voicevox_engine/user_dict/user_dict_word.py index 3ddf3e033..3637c1bd4 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, @@ -16,20 +15,19 @@ MAX_PRIORITY = USER_DICT_MAX_PRIORITY -class PartOfSpeechDetail(BaseModel): - """ - 品詞ごとの情報 - """ +@dataclass +class PartOfSpeechDetail: + """品詞ごとの情報""" - 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") + 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は辞書の左・右文脈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="アクセント結合規則の一覧") + context_id: int + cost_candidates: list[int] # コストのパーセンタイル + accent_associative_rules: list[str] # アクセント結合規則の一覧 part_of_speech_data: dict[WordTypes, PartOfSpeechDetail] = { From eb97781f05f3ecbd4c7c19d2d902e9d120510c53 Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 12 Jun 2024 01:46:37 +0000 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E9=9B=86=E7=B4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- voicevox_engine/user_dict/user_dict_word.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/voicevox_engine/user_dict/user_dict_word.py b/voicevox_engine/user_dict/user_dict_word.py index 3637c1bd4..bfa992bc3 100644 --- a/voicevox_engine/user_dict/user_dict_word.py +++ b/voicevox_engine/user_dict/user_dict_word.py @@ -23,9 +23,7 @@ class PartOfSpeechDetail: part_of_speech_detail_1: str # 品詞細分類1 part_of_speech_detail_2: str # 品詞細分類2 part_of_speech_detail_3: str # 品詞細分類3 - # context_idは辞書の左・右文脈IDのこと - # https://github.com/VOICEVOX/open_jtalk/blob/427cfd761b78efb6094bea3c5bb8c968f0d711ab/src/mecab-naist-jdic/_left-id.def # noqa - context_id: int + 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] # アクセント結合規則の一覧 From 535b0456ae067bb62d334c5a6b5fbd8b3a43b49d Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 19 Jun 2024 06:46:01 +0000 Subject: [PATCH 3/3] =?UTF-8?q?add;=20dataclass=20=E3=81=AE=E5=87=8D?= =?UTF-8?q?=E7=B5=90=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- voicevox_engine/user_dict/user_dict_word.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voicevox_engine/user_dict/user_dict_word.py b/voicevox_engine/user_dict/user_dict_word.py index 537aa7f4a..ff14dd61b 100644 --- a/voicevox_engine/user_dict/user_dict_word.py +++ b/voicevox_engine/user_dict/user_dict_word.py @@ -12,7 +12,7 @@ ) -@dataclass +@dataclass(frozen=True) class _PartOfSpeechDetail: """品詞ごとの情報"""