The Wayback Machine - https://web.archive.org/web/20200915002441/https://github.com/zake7749/word2vec-tutorial
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

使用 gensim 訓練中文詞向量

教學文件

套件需求

  • jieba
pip3 install jieba
  • gensim
pip3 install -U gensim
  • OpenCC (可更換為任何繁簡轉換套件)

訓練流程

1.取得中文維基數據,本次實驗是採用 2016/8/20 的資料。

目前 8 月 20 號的備份已經被汰換掉囉,請前往維基百科:資料庫下載按日期來挑選更新的訓練資料。( 請挑選以pages-articles.xml.bz2為結尾的檔案 )

2.將下載後的維基數據置於與專案同個目錄,再使用wiki_to_txt.py從 xml 中提取出維基文章

python3 wiki_to_txt.py zhwiki-20160820-pages-articles.xml.bz2

若您採用的不是 8 月 20 號的備份,請更換 zhwiki-20160820-pages-articles.xml.bz2 為您採用的備份的檔名。

3.使用 OpenCC 將維基文章統一轉換為繁體中文

opencc -i wiki_texts.txt -o wiki_zh_tw.txt -c s2tw.json

4.使用jieba 對文本斷詞,並去除停用詞

python3 segment.py

5.使用gensim 的 word2vec 模型進行訓練

python3 train.py

6.測試我們訓練出的模型

python3 demo.py

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.