I have a dataset of reviews from TripAdvisor and I would like to translate non-English reviews into English.
The reviews are in many different languages: my dataset contains reviews in 44 different languages including English reviews which are around a quarter of the total, followed by Italian, German, Spanish and French reviews which are respectively 14%, 11% 6%, and 5.5% of the reviews.
I detect the different languages using the langdetect
package.
from langdetect import detect
language = detect(title)
Then I tried to use the package googletrans to translate the text. However, when I tried to perform a small test I get the following error:
from googletrans import Translator
translator = Translator()
translator.translate('Buongiorno mi chiamo Alberto')
Does anyone know a way to translate reviews (knowing or not the language ) to English using python for a dataset of around 10k reviews?
from translate import Translator translator= Translator(to_lang="German") translation = translator.translate("Good Morning!") print translation
$\endgroup$