Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation not working - NotTranslated: Translation API returned the input string unchanged. #117

Closed
edgaralts opened this issue Feb 15, 2016 · 13 comments

Comments

@edgaralts
Copy link

Hi,
The translation is not working.
thanks in advance,

In [1]: from textblob import TextBlob

In [2]: en_blob = TextBlob(u'Simple is better than complex.')

In [3]: en_blob.translate(to='es')

NotTranslated Traceback (most recent call last)
in ()
----> 1 en_blob.translate(to='es')

/usr/local/lib/python2.7/dist-packages/textblob-0.11.0-py2.7.egg/textblob/blob.pyc in translate(self, from_lang, to)
507 from_lang = self.translator.detect(self.string)
508 return self.class(self.translator.translate(self.raw,
--> 509 from_lang=from_lang, to_lang=to))
510
511 def detect_language(self):

/usr/local/lib/python2.7/dist-packages/textblob-0.11.0-py2.7.egg/textblob/translate.pyc in translate(self, source, from_lang, to_lang, host, type_)
43 return self.get_translation_from_json5(json5)
44 else:
---> 45 raise NotTranslated('Translation API returned the input string unchanged.')
46
47 def detect(self, source, host=None, type
=None):

NotTranslated: Translation API returned the input string unchanged.

@Gijs-Koot
Copy link

The problem is that this API has changed it's output format. See http://stackoverflow.com/questions/35420602/python-textblob-not-translating/35421116#35421116.

@sanjaydeo96
Copy link

Use this:
Step (1) pip install goslate

Step (2)
import goslate

text = "Hello World"

gs = goslate.Goslate()
translatedText = gs.translate(text,'hi')

print(translatedText)

@mostafagafer
Copy link

@sanjaydeo96

can you please tell me how to apply this into a pandas dataframe ?
I have a column df['Text'] which contain text from differen languages and I want to translate it into an new column called df['Text transalted']

@OtavioAugusto
Copy link

OtavioAugusto commented Dec 19, 2018

@sanjaydeo96

can you please tell me how to apply this into a pandas dataframe ?
I have a column df['Text'] which contain text from differen languages and I want to translate it into an new column called df['Text transalted']

You can do something like this:

from textblob import TextBlob

for index, row in df.iterrows():
    zh_blob = df.iloc[index]['Text']
    translation = TextBlob(zh_blob)
    en_blob = translation.translate(from_lang='zh', to='en')
    df.at[index, str('Text translated')] = str(en_blob )
df.head()

@mostafagafer
Copy link

Thanks you are the best, I'll try the code as soon I set on my computer. thanks a million

@mostafagafer
Copy link

it gave me error :

NotTranslated: Translation API returned the input string unchanged.

any comment on how to fix it ?!
and in your code :
en_blob = translation.translate(from_lang='zh', to='en')
how to make it translate from any language to en not only from zh ?
again, thanks for your answer

@OtavioAugusto
Copy link

OtavioAugusto commented Dec 19, 2018

it gave me error :

NotTranslated: Translation API returned the input string unchanged.

any comment on how to fix it ?!
and in your code :
en_blob = translation.translate(from_lang='zh', to='en')
how to make it translate from any language to en not only from zh ?
again, thanks for your answer

Basically, you only need to remove from_lang='zh', and TextBlob will attempt to detect the language
en_blob = translation.translate(to='en')

You can see more information here: https://textblob.readthedocs.io/en/dev/quickstart.html#translation-and-language-detection

About the error i think this can help you: https://github.com/sloria/TextBlob/issues/171#issuecomment-354914127
https://stackoverflow.com/a/35421116/7919290

@polpokpol
Copy link

i thought im the only one

@kiran14997
Copy link

Use this:
Step (1) pip install goslate

Step (2)
import goslate

text = "Hello World"

gs = goslate.Goslate()
translatedText = gs.translate(text,'hi')

print(translatedText)

hi sir I'm getting this following error
HTTPError: HTTP Error 503: Service Unavailable

@SyahirahWanMin
Copy link

try:
blob.translate(from_lang = 'en', to = 'es')
except:
print ("Same translation so skipping")

@kiran14997
Copy link

kiran14997 commented Oct 16, 2019 via email

@RODBLWA
Copy link

RODBLWA commented Feb 2, 2021

how Translate English texts database into Arabic textblob pytho?

@shubheshswain91
Copy link

shubheshswain91 commented Oct 14, 2021

I am facing a problem with the translation

from textblob import TextBlob
from textblob.translate import NotTranslated

text = TextBlob("Explanation\nWhy the edits made under my username Hardcore Metallica Fan were reverted? They weren't vandalisms, just closure on some GAs after I voted at New York Dolls FAC. And please don't remove the template from the talk page since I'm retired now.89.205.38.27")
text = text.translate(from_lang='en', to='de')
print(text)

Result:
TextBlob("Explanation Why the edits made under my username Hardcore Metallica Fan were reverted? Erklärung Warum wurden die unter meinem Benutzernamen Hardcore Metallica Fan vorgenommenen Änderungen rückgängig gemacht? They weren't vandalisms, just closure on some GAs after I voted at New York Dolls FAC. Es waren keine Vandalismen, sondern nur die Schließung einiger GAs, nachdem ich bei New York Dolls FAC abgestimmt hatte. And please don't remove the template from the talk page since I'm retired now.89.205.38.27 Und bitte entfernen Sie die Vorlage nicht von der Diskussionsseite, da ich jetzt im Ruhestand bin.89.205.38.27")

It is giving me the original as well as the translated version. Also, it's giving me result in the some HTML format like ",&# " etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants