1

While parsing a large text, and translating English language into Hindi, this error arises. JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I have tried initializing the api in every loop. Still no result. Tried again after 2 days, the error still arises. How to know if my IP is getting blocked?

eng_words= []
for i in nltk_tokens:
    translator = Translator()
    langs = translator.detect(i)
    if all( [langs.lang == "en", langs.confidence > 0.91] ):
        eng_words.append(i)
    else:
        language = translator.translate(i, dest='hi')
        word = language.text

 Error :  
 <ipython-input-12-a89f1985a6a7> in detect_lang(nltk_tokens)
  4     translator = Translator()
  5     for i in nltk_tokens:
  ----> 6         langs = translator.detect(i)
  7         if all( [langs.lang == "en", langs.confidence > 0.91] ):
  8             eng_words.append(i)

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

1 Answers1

0

I'm pretty sure your IP would have gotten blocked from too many requests(Google has a translate API that costs money to use so they want to stop free usage from other apis). The normal way to check if you are blocked is to check if you get a 5xx HTTP error response.

GoogleTrans API Error - Expecting value: line 1 column 1 (char 0)

Cameron
  • 76
  • 2
  • The answer you have given is a link to a question, if you find such duplicate questions you must flag the question as duplicate because it already has an answer. – Rahul Jun 01 '19 at 08:11