Refactor: change execution location of pyopenjtalk.initialize()
Considering library design, this function with many side effects should not be executed in a library.
This commit is contained in:
@@ -112,10 +112,6 @@ def text_to_sep_kata(
|
||||
tuple[list[str], list[str]]: 分割された単語リストと、その読み(カタカナ or 記号1文字)のリスト
|
||||
"""
|
||||
|
||||
# pyopenjtalk_worker を初期化
|
||||
## 一度 worker を起動すれば、明示的に終了するかプロセス終了まで同一の worker に接続される
|
||||
pyopenjtalk.initialize()
|
||||
|
||||
# parsed: OpenJTalkの解析結果
|
||||
parsed = pyopenjtalk.run_frontend(norm_text)
|
||||
sep_text: list[str] = []
|
||||
@@ -249,10 +245,6 @@ def __pyopenjtalk_g2p_prosody(text: str, drop_unvoiced_vowels: bool = True) -> l
|
||||
return -50
|
||||
return int(match.group(1))
|
||||
|
||||
# pyopenjtalk_worker を初期化
|
||||
## 一度 worker を起動すれば、明示的に終了するかプロセス終了まで同一の worker に接続される
|
||||
pyopenjtalk.initialize()
|
||||
|
||||
labels = pyopenjtalk.make_label(pyopenjtalk.run_frontend(text))
|
||||
N = len(labels)
|
||||
|
||||
|
||||
@@ -80,10 +80,6 @@ def update_dict(
|
||||
コンパイル済み辞書ファイルのパス
|
||||
"""
|
||||
|
||||
# pyopenjtalk_worker を初期化
|
||||
## 一度 worker を起動すれば、明示的に終了するかプロセス終了まで同一の worker に接続される
|
||||
pyopenjtalk.initialize()
|
||||
|
||||
random_string = uuid4()
|
||||
tmp_csv_path = compiled_dict_path.with_suffix(
|
||||
f".dict_csv-{random_string}.tmp"
|
||||
|
||||
Reference in New Issue
Block a user