This commit is contained in:
雅诺狐
2025-10-06 21:02:44 +08:00
2 changed files with 3 additions and 1 deletions

View File

@@ -56,7 +56,9 @@ class ChineseTypoGenerator:
# 使用内置的词频文件
char_freq = defaultdict(int)
dict_path = os.path.join(os.path.dirname(__file__), "dict.txt")
# 从当前文件向上返回三级目录到项目根目录,然后拼接路径
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
dict_path = os.path.join(base_dir, "depends-data", "dict.txt")
# 读取rjieba的词典文件
with open(dict_path, encoding="utf-8") as f: