From Hola to Hello with Polyglotr

Brianna Brooks

Smile and Nod?

Lost in Translation 😅🌎💬

  • Multilingual environments can result in confusion and misunderstanding!
    • Real world data is multilingual and not uniform
    • Hard to analyze consistently

Tongues Finally Untied: polyglotr 🗣️✨

Creator: Tomer Iwan

Year: 2024

polyglotr is an R package that:

  • serves as a language translation tool for the R programming language
  • enables consistent analysis and insights across diverse linguistic data sources

polyglotr in the Real World!💬🌎✨

Examples of use in multilingual environments include:

  • Product Reviews
  • Social Media Analysis (ex. Video Comments, etc.)
  • Customer Support Automation
  • Intelligence

polyglotr in action! 🌐✨

The code below is an excerpt from the Language Detection and Conditional Translation Vignette. It:

  • Automatically detects languages
  • Translates non-English content
# Core Functions

# Skip English
if (detected_lang == "en") {
  return(tibble(
    original_text = input_text,
    english_text = input_text,
    was_translated = FALSE,
    detected_language = detected_lang
  ))
}

# Translate non-English (with error handling)
translated_text <- tryCatch(
  google_translate(input_text, "auto", target_language),
  error = function(e) "[TRANSLATION FAILED]"
)

Input and Output:

# Input
id user_feedback                                                           
  <int> <chr>                                                                            
1 Great product, very satisfied!                                
2 Excelente producto, muy satisfecho!                     
3 Produit fantastique, je le recommande!              
4 This service exceeded my expectations.               
5 Der Service war wirklich hervorragend.                 

# Output
 <chr>                                  <lgl>          <chr>            
1 Great product, very satisfied!         FALSE          en               
2 Excellent product, very satisfied!     TRUE           es               
3 Fantastic product, I recommend it!     TRUE           fr               
4 This service exceeded my expectations. FALSE          en               
5 The service was really excellent.      TRUE           de               

Real World Application:

Detection and Translation of Multilingual Social Media Comments

Detection and Translation of Multilingual Social Media Comments

I used polyglotr to translate multilingual comments from Guns N’ Roses’ “November Rain” music video 🤘🌍

  • detects the language
  • returns a translation of the comment
# Input 
mixed_data <- tibble(
  id = 1:8,
  user_feedback = c(
    "In my opinion, one of the best bands in the world.",
    "Siempre me encanta..así yo no entienda nada.hasta me hace llorar!",
    "La France t’AIME.",
    "Einfach episch.")
)
# Output 
1 In my opinion, one of the best bands in the world.                                                  FALSE  
2 I always love it... even if I don't understand anything. It even makes me cry!                      TRUE
3 France LOVES you.                                                                                   TRUE  
4 Simply epic.                                                                                        TRUE   

Say It Right, Say It All 🔥🗣️

  • polyglotr successfully detected and translated the comments provided as input text

  • Caveat: the input must be a certain length for the language to be detected accurately

Making the World Understandable, One Translation at a Time

“If you talk to a man in a language he understands, that goes to his head. If you talk to him in his language, that goes to his heart.” — Nelson Mandela

  • polyglotr breaks down linguistic barriers and allows for

    • More consistent analysis
    • Better decision-making
    • Greater inclusivity across global audiences

Gracias

Merci

Danke

ありがとう

Grazie

Obrigado

Thank You

감사합니다

شكرًا

धन्यवाद

References

Link to GitHub Repository:

  • https://github.com/madisonbri06-cpu/Polyglotr-Translating-and-Detecting-Languages-in-a-Diverse-and-Multilingual-World.git

Link to YouTube Video:

  • https://www.youtube.com/watch?v=BGvyilqNIHc

Link to Language Detection and Conditional Translation Vignette:

  • https://tomeriko96.r-universe.dev/articles/polyglotr/language-detection-conditional-translation.html