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 .
原文地址:https://www.cnblogs.com/lingwang3/p/14373442.html