python 語種識別的幾種方法


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 .

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM