Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Aug 18, 2024
1 parent a393633 commit afa9587
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- encoding: utf-8 -*-
"""基础文件"""

import json
from pathlib import Path
from typing import TypeAlias, Dict, Set, Tuple

import ujson

# 当前绝对路径
P = Path(__file__).resolve().parent

Expand All @@ -25,7 +26,7 @@ def load_json(file: str, folder: str = "data") -> Ldata:
"""

with open(P / folder / f"{file}.json", "r", encoding="utf-8") as f:
return json.load(f)
return ujson.load(f)


def file_size(p: Path):
Expand Down
4 changes: 2 additions & 2 deletions converter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- encoding: utf-8 -*-
"""难视语言转换器"""

import json
import re
import time
import inspect
from typing import List, Set, Tuple, Callable, Optional

import ujson
from romajitable import to_kana as tk
from pypinyin import Style, lazy_pinyin, load_phrases_dict
from pypinyin_dict.phrase_pinyin_data import cc_cedict, di
Expand Down Expand Up @@ -432,6 +432,6 @@ def save_to_json(
input_dict, elapsed_time = input_data
file_path = P / output_folder / f"{output_file}.json"
with open(file_path, "w", encoding="utf-8") as j:
json.dump(input_dict, j, indent=2, ensure_ascii=False)
ujson.dump(input_dict, j, indent=2, ensure_ascii=False)
size = file_size(file_path)
print(f"已生成语言文件“{output_file}.json”,大小{size},耗时{elapsed_time:.2f} s。")
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ jieba>=0.42.1
pypinyin>=0.52.0
pypinyin_dict>=0.8.0
Requests>=2.32.3
rich>=13.7.1
romajitable>=0.0.1
opencc >= 1.1.9
ujson>=5.10.0

0 comments on commit afa9587

Please sign in to comment.