为什么在python的文档生成器-sphinx 搜索栏中找不到cjk(chinese) 词的搜索结果?
Why no search result for the cjk(chinese) word in python's documentation generator--sphinx search bar?
我建了一个简单的项目,里面只有一篇文章,标题是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库
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
.
编辑狮身人面像的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.
现在可以搜索汉字了。
我建了一个简单的项目,里面只有一篇文章,标题是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库
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
.
编辑狮身人面像的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.
现在可以搜索汉字了。