From 3648b4af81d6bf56249f7781072e87c61b8ff951 Mon Sep 17 00:00:00 2001 From: Artrajz <969242373@qq.com> Date: Tue, 9 Jan 2024 13:08:26 +0800 Subject: [PATCH] Update phrases_dict.py --- utils/phrases_dict.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/phrases_dict.py b/utils/phrases_dict.py index fe46ba5..70dc925 100644 --- a/utils/phrases_dict.py +++ b/utils/phrases_dict.py @@ -4,15 +4,15 @@ import jieba import pypinyin from pypinyin_dict.phrase_pinyin_data import large_pinyin -from pypinyin_dict.pinyin_data import cc_cedict, kxhc1983 +from pypinyin_dict.pinyin_data import cc_cedict import config phrases_dict = { "一骑当千": [["yí"], ["jì"], ["dāng"], ["qiān"]], - "桔子": [["jú"], ["zǐ"]], + "桔子": [["jú"], ["zi"]], "重生": [["chóng"], ["shēng"]], - "重重地":[["zhòng"], ["zhòng"], ["dě"]], + "重重地":[["zhòng"], ["zhòng"], ["de"]], "自少时":[["zì"], ["shào"], ["shí"]], } @@ -24,7 +24,7 @@ def load_phrases_from_file(file_path): phrases_dict.update(additional_phrases) logging.info(f"Additional phrases loaded from {file_path}") except FileNotFoundError: - logging.warning(f"File {file_path} not found. You can create {file_path} and write your phrases_dict.") + logging.debug(f"File {file_path} not found. You can create {file_path} and write your phrases_dict.") except Exception as e: logging.error(f"Error loading additional phrases from {file_path}: {str(e)}") @@ -35,6 +35,7 @@ def phrases_dict_init(): cc_cedict.load() additional_phrases_file = config.ABS_PATH + "/phrases_dict.txt" load_phrases_from_file(additional_phrases_file) + for word in phrases_dict.keys(): jieba.add_word(word) pypinyin.load_phrases_dict(phrases_dict)