1.langid
2.langdetect
3.fasttext
本文主要講fasttext
下載它的model,當然可以自己訓練
import fasttext fasttext_model = fasttext.load_model('xx/bin/lid.bin') labels, scores = fasttext_model.predict("hello everyone! my name is lingwang3", k=1) print(labels, scores)
4.安裝fasttext
【安裝出現gcc版本錯誤,請參考https://www.cnblogs.com/new-journey/p/11356647.html】
使用 cmake 命令安裝 fasttext(可以只安裝python版本)
yum install git/cmake
$ git clone https://github.com/facebookresearch/fastText.git $ cd fastText $ mkdir build && cd build && cmake .. $ make && make install
為 python 安裝 fasttext
$ git clone https://github.com/facebookresearch/fastText.git $ cd fastText $ pip install .