lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

how to translate a column having multiple languages #23

Open Rahulsunny11 opened 3 years ago

Rahulsunny11 commented 3 years ago

Hi, thanks for this amazing library I am working on twitter data.. it has column named full_text where text is available in multiple languages I want to translate all rows into english langugae thanks

lushan88a commented 3 years ago

I don’t know what the structure of twitter data is, can you show it?

Rahulsunny11 commented 3 years ago

Screenshot (6)

this is how it looks.. here full_text column has tweets in multiple languages, I want to translate to english

lushan88a commented 3 years ago
full_text = XXXX
translator = google_translator(url_suffix="com",timeout=5)  
translate_text = translator.translate(full_text,lang_tgt='en')  

Just set lang_tgt=‘en’.

Rahulsunny11 commented 3 years ago

thanks will try and let you know if there is an issue

Rahulsunny11 commented 3 years ago

this is working fine but I am having trouble in applying this on whole columns from the above I want to create a new translated column named 'text'

I tried following code `df["English"] = ""

for index, row in df.iterrows(): translator = google_translator(url_suffix="com",timeout=5) eng_text = translator.translate(row["full_text"], lang_tgt="en") row["English"] = eng_text`

brendachirata commented 3 years ago

@Rahulsunny11 what did you end up doing. Im running into many problems trying to translate a dataframe with 10000 rows that are in 7 languages into english. Can you help me with the leads that helped you? Thank you

Rahulsunny11 commented 3 years ago

@Rahulsunny11 what did you end up doing. Im running into many problems trying to translate a dataframe with 10000 rows that are in 7 languages into english. Can you help me with the leads that helped you? Thank you

Hi @brendachirata apologies for late reply. I have tried everything but didn't succeed in translating using any library, So now I am using google translator(https://translate.google.co.in/?sl=auto&tl=en&op=docs) to translate text.

Thanks