Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 09:48 AM
Hi Team,
I am looking to convert languages (Chines) into English or any other format. Do we have any function in incorta to use in formula column or any other suggestion.
Solved! Go to Solution.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2023 08:48 AM - edited ‎08-18-2023 08:49 AM
@danishnov - Here's a video and script of my solution:
import pandas as pd
from translate import Translator
df = read("Translation.Translations")
pdf = df.toPandas()
def translate_to_english(chinese_text):
try:
translator = Translator(to_lang="en", from_lang="zh")
translation = translator.translate(chinese_text)
return translation
except Exception as e:
print(f"Error translating '{chinese_text}': {e}")
return ""
# Apply translation function to the 'Chinese_Phrase' column and create a new 'English_Translation' column
pdf['Machine_Translation'] = pdf['Chinese_Phrase'].apply(translate_to_english)
df_all = spark.createDataFrame(pdf)
save(df_all)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2023 08:13 AM
Thank you @JoeM ,
The Code you have shared is obsolutely working fine. Below is the screenshot how it translated.
Regards,
Shashidhar.S
