sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.61k stars 2.13k forks source link

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

Closed Snoopy1866 closed 1 month ago

Snoopy1866 commented 1 month ago

Subject: if user do not set the dict option, fallback to the default dict provided by jieba

Feature or Bugfix

Purpose

Detail

Relates

picnixz commented 1 month ago

AFAICT, this would leave a file descriptor opened (jieba.get_dict_file() opens a file in read mode). So ideally, we should find a way to retrieve the default dict path without having to open the file. Would it be possible?

Snoopy1866 commented 1 month ago

@picnixz yes, because the default dict is installed with jieba, so we can directly get its path using os.path.join(os.path.dirname(jieba.__file__), "dict.txt")