4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonで言語判定をする[pycld2]

Last updated at Posted at 2019-09-01

pycld2インストール

OSはUbuntuで行っていますが、
Windowsの場合、適切なコンパイラがない場合はVC++のコンパイラを用意する必要があるようです
(面倒なので私は未実施)


git clone http://github.com/abosamoor/pycld2.git
cd pycld2
sudo python3 ./setup.py install

# もしpython.h云々のエラーが出たら適宜このあたりをインストール
sudo apt-get install python2.7-dev
sudo apt-get install python3-dev


言語判定の一例

英語かどうかを判定するとき。

isReliable, textBytesFound, details = cld2.detect("This is a pen.")
if "en" == details[0][1]:
    print("英語です!")

参考

pycld2 0.31

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?