簡體   English   中英

為什么在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股票歷史數據下載 &#8212; 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

找到解霸字典文件。

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.

現在可以搜索漢字了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM