python - Langid detect language showing wrong result in #Python
问题描述
I need to detect the language of the strings stored below.
0 nice
1 Insane3
2 NaN
3 @bertelsen1986
4 20 or 30 mm rise on the Renthal Fatbar?
Name: Comments, dtype: object
Using langid
module to detect the language of the comments stored in df['Comments']
:
import langid
for row in df['Comments']:
lang, log_prob = langid.classify(row)
TM['Detected_Language']=lang
Below is the result, which is wrong:
Comments Detected_Language
0 nice zh
1 Insane3 zh
2 ❤️ zh
3 @bertelsen1986 zh
4 20 or 30 mm rise on the Renthal Fatbar? zh
The comments should return an 'en' instead. (In the dataset, there are comments with other languages)
解决方案
推荐阅读
- ruby-on-rails - 为什么我的 Rails 应用程序中的 lograge 会影响 ECS/Fargate 环境中的 CloudWatch 日志记录?
- arrays - 在结构指针代码中输入错误
- javascript - 在处理深度嵌套的对象数组时,在 map() 中使用多个 reduce() 函数的替代方法?
- java - JSON 对象无法从 START_OBJECT 令牌中反序列化 `java.lang.String` 的实例
- java - 如何使用实时 Firebase 数据库计算两点之间的距离,并显示他当前行进的距离?
- c++ - 为什么调用函数时指针会改变地址?
- codeigniter - 使用活动记录计算利润、收入和费用 codeigniter 4
- elasticsearch - 为什么 DSL 对查询字符串搜索的评分为 1.0
- c - 八进制或十六进制数在C中转换为十进制
- raspberry-pi - 其他树莓派上的 pyinstaller 可执行文件无法执行