1、安装、使用
- langid 目前支持 97 种语言的检测
pip install langid
- 使用测试 ```python import langid
def get_lang(text): tp_lang_score = langid.classify(text) return tp_lang_score
s1 = “本篇博客主要介绍两款语言探测工具,用于区分文本到底是什么语言,” s2 = ‘We are pleased to introduce today a new technology – Record Matching –that automatically finds relevant historical records for every family tree on MyHerit’ s3 = “Javigator:Java代码导读及分析管理工具的设计”
print(get_lang(s1)) print(get_lang(s2)) print(get_lang(s3))
“”” (‘zh’, -461.7451400756836) (‘en’, -264.470148563385) (‘zh’, -206.2425878047943) “”” ```