Я пытаюсь перевести неанглийские тексты на английский с помощью textblob.Я читаю документацию и пытаюсь обработать возможные исключения, как показано ниже:
txt=" "
for word in text.split():
try:
w=TextBlob(word)
w=w.translate(to='en')
except TranslatorError(TextBlobError):
word=" " #replace word with space
txt=txt+word
except NotTranslated(TextBlobError):
txt=txt+word+" "
else:
txt=txt+w+" "
print(txt)
Я получаю следующие ошибки:
except TranslatorError(TextBlobError):
NameError: name 'TranslatorError' is not defined
raise NotTranslated('Translation API returned the input string unchanged.')
textblob.exceptions.NotTranslated: Translation API returned the input string unchanged.
Я ссылался на следующую ссылку: https://textblob.readthedocs.io/en/dev/api_reference.html#textblob.exceptions.TextBlobError
Я не могу устранить эти ошибки.Пожалуйста, помогите!