Skip to content

Commit

Permalink
Update phrases_dict.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Artrajz committed Jan 9, 2024
1 parent 1b89d8c commit 3648b4a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utils/phrases_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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ú"], [""]],
"桔子": [["jú"], ["zi"]],
"重生": [["chóng"], ["shēng"]],
"重重地":[["zhòng"], ["zhòng"], [""]],
"重重地":[["zhòng"], ["zhòng"], ["de"]],
"自少时":[["zì"], ["shào"], ["shí"]],
}

Expand All @@ -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)}")

Expand All @@ -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)

0 comments on commit 3648b4a

Please sign in to comment.