Python - JSONDecodeError: Extra data: line 1 column 350 (char 349)

 
Vista:

JSONDecodeError: Extra data: line 1 column 350 (char 349)

Publicado por Daniel (1 intervención) el 30/09/2021 01:13:44
Hola a todos me encuentro realizando el analisis de sentimiento usando Google transalate

1
2
3
4
5
6
7
8
9
10
11
traductor = google_translator()
 
texto = df["Comentarios"]
 
texto_trad = pd.Series([])
 
for cont in range(len(texto)):
    traduccion = traductor.translate(texto[cont], lang_src='es', lang_tgt='en')
    text_trad[cont] = traduccion
 
print(text_trad)


el error es el siguiente:

JSONDecodeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_7612/1617790326.py in <module>
6
7 for cont in range(len(texto)):
----> 8 traduccion = traductor.translate(texto[cont], lang_src='es', lang_tgt='en')
9 text_trad[cont] = traduccion
10

~\AppData\Local\Programs\Python\Python39\lib\site-packages\google_trans_new\google_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
186 return [sentences, pronounce_src, pronounce_tgt]
187 except Exception as e:
--> 188 raise e
189 r.raise_for_status()
190 except requests.exceptions.ConnectTimeout as e:

~\AppData\Local\Programs\Python\Python39\lib\site-packages\google_trans_new\google_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
150 try:
151 response = (decoded_line + ']')
--> 152 response = json.loads(response)
153 response = list(response)
154 response = json.loads(response[0][2])

~\AppData\Local\Programs\Python\Python39\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
348 cls = JSONDecoder

~\AppData\Local\Programs\Python\Python39\lib\json\decoder.py in decode(self, s, _w)
338 end = _w(s, end).end()
339 if end != len(s):
--> 340 raise JSONDecodeError("Extra data", s, end)
341 return obj
342

JSONDecodeError: Extra data: line 1 column 350 (char 349)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder