在Python中使用googletranslate包进行错误:期望值:第1行第1列(字符0) [英] Errow using googletranslate package in Python: Expecting value: line 1 column 1 (char 0)

查看:295
本文介绍了在Python中使用googletranslate包进行错误:期望值:第1行第1列(字符0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从twitter提取了推文,现在尝试将文本转换为英语.它应该检测源语言本身并转换为英语.

I have extracted the tweets from twitter and now trying to convert the text to English. It should detect the source language itself and convert to English.

这是我正在使用的代码:

This is the code i'm using:

from googletrans import Translator

translator = Translator()

tweet['English']= tweet['text_clean'].apply(translator.translate,dest='en').apply(getattr, args=('text',))

起初它一直在工作,但现在不再工作.尝试关闭jupyter笔记本并重新启动.即使处理1条记录,它也会产生相同的错误:

It was working initially but not anymore. Tried closing the jupyter notebook and restarting it again. It gives the same error even for processing 1 record:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

有什么解决方法吗?

我已经在此处阅读有关stackoverflow的帖子和问题,并尝试了以下操作:

I have already read posts and questions here on stackoverflow regarding this and tried the following:

1)纯文本:删除了网址,表情符号,空白行,标点符号等.

1) Clean Text: Removed URL, smileys, blank rows, punctuation and etc.

2)使用块批量处理数据,以处理Google Translate API限制点.

2) Processed data in batches using chunk in order to deal with Google Translate API limit point.

推荐答案

现在工作正常,昨天似乎是API问题.

It's working fine now, seems to be a API issue yesterday.

这篇关于在Python中使用googletranslate包进行错误:期望值:第1行第1列(字符0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆