python-3.x - 为什么python的文档生成器--sphinx搜索栏中没有cjk(chinese)词的搜索结果?
问题描述
我建立了一个简单的项目,它只包含一篇文章,标题是 yahoo股票历史数据下载
,文件yahoo股票历史数据下载.rst
,只包含一个问题:为何可以通过浏览器下载yahoo股票历史数据,无法使用wget curl下载?
英文句子字符串可以搜索。
使用 grep 命令搜索 cjk(中文)单词“股票”。
grep -n -r "股票" myproject
/source/research/yahoo股票历史数据下载.rst:yahoo股票历史数据下载
/source/research/yahoo股票历史数据下载.rst:问题:为何可以通过浏览器下载yahoo股票历史数据,无法使用wget curl下载?
/build/html/research/yahoo股票历史数据下载.html: <title>1. yahoo股票历史数据下载 — documents 1 documentation</title>
/build/html/research/yahoo股票历史数据下载.html:<h1>1. yahoo股票历史数据下载<a class="headerlink" href="#yahoo" title="Permalink to this headline">¶</a></h1>
/build/html/research/yahoo股票历史数据下载.html:<p>问题:为何可以通过浏览器下载yahoo股票历史数据,无法使用wget curl下载?</p>
/build/html/research/yahoo股票历史数据下载.html:<li class="toctree-l1 current"><a class="current reference internal" href="#">1. yahoo股票历史数据下载</a></li>
/build/html/research/yahoo股票历史数据下载.html: <a href="../_sources/research/yahoo股票历史数据下载.rst.txt"
在python的文档生成器--sphinx搜索栏中搜索cjk(中文)单词“股票”。
可以看到,yahoo
无论是标题还是内容中的第一个词,标题和内容中的第二个词都是股票
要搜索的目标。
为什么您的搜索没有匹配任何文件?
解决方案
安装jieba lib。
sudo pip install jieba
找到jieba字典文件。
sudo find /usr -name "jieba"
/usr/local/lib/python3.5/dist-packages/jieba
ls /usr/local/lib/python3.5/dist-packages/jieba
analyse dict.txt __init__.py posseg
_compat.py finalseg __main__.py __pycache__
jieba 词典文件位于/usr/local/lib/python3.5/dist-packages/jieba/dict.txt
.
编辑 sphinx 的 conf.py。
vim source/conf.py
html_search_language = 'zh'
html_search_options = {'dict': '/usr/local/lib/python3.5/dist-packages/jieba/dict.txt'}
重新编译项目目录中的所有文件。
cd yourproject
make html
重启apache2。
sudo systemctl restart apache2 #maybe it is not neccessary.
现在可以搜索汉字了。
推荐阅读
- excel - vba MID 函数使我的撇号不可见
- python-3.x - Dash python plotly 实时更新表
- android - Android - Appium 的模拟位置将被 Wi-Fi、蓝牙和移动网络覆盖
- ms-access - 使用具有不同表源的相同查询和报告 - MS Access
- python - opencv Python创建循环以显示图像错误
- matlab - MATLAB 遗传算法,f-count 看起来比预期的要高
- javascript - 如何在列表中随机数标签的单词中剪切部分字符串?
- mysql - 了解 SQL 别名
- fortran - 警告 #10145 没有对文件“A.obj”执行任何操作
- python - pip-18.0 出现“找不到日志记录模块”错误