Use the default Jieba dict for Chinese search if not set (#13005)

This commit is contained in:
Kun Jinkao 2024-10-20 02:43:57 +08:00 committed by GitHub
parent 25ad2a031e
commit 80642f6524
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -234,7 +234,10 @@ class SearchChinese(SearchLanguage):
def init(self, options: dict[str, str]) -> None: def init(self, options: dict[str, str]) -> None:
if JIEBA: if JIEBA:
dict_path = options.get('dict') default_dict_path = os.path.join(
os.path.dirname(jieba.__file__), jieba.DEFAULT_DICT_NAME
)
dict_path = options.get('dict', default_dict_path)
if dict_path and os.path.isfile(dict_path): if dict_path and os.path.isfile(dict_path):
jieba.load_userdict(dict_path) jieba.load_userdict(dict_path)