Skip to main content

A translation tool for multiple languages.

Project description

TranslatorAR

TranslatorAR is a Python package designed for translating text between Arabic, English, and French. The package uses the Hugging Face Transformers library to perform translations and supports translating text extracted from PDF files.

Features

  • Text Translation: Translate text between Arabic, English, and French.
  • PDF Translation: Extract text from PDF files and translate it into different languages.
  • Customizable: Easily extendable to support additional language pairs.

Usage

Here are some examples of how to use the TranslatorAR package:

1. Translate Text

from translatorAR import TranslatorAR

translator = TranslatorAR()

text_ar_en = "هذا المساق مقدم من Hugging Face."
translated_text_ar_en = translator.translate(text_ar_en, "ar", "en")
print(f"Arabic to English: {translated_text_ar_en}")

text_en_ar = "This course is produced by Hugging Face."
translated_text_en_ar = translator.translate(text_en_ar, "en", "ar")
print(f"English to Arabic: {translated_text_en_ar}")

text_ar_fr = "أهلاً وسهلاً بكم في هذا المساق."
translated_text_ar_fr = translator.translate(text_ar_fr, "ar", "fr")
print(f"Arabic to French: {translated_text_ar_fr}")

text_fr_ar = "Bienvenue dans ce cours."
translated_text_fr_ar = translator.translate(text_fr_ar, "fr", "ar")
print(f"French to Arabic: {translated_text_fr_ar}")

2. Translate PDF

translator = TranslatorAR()

# Translate Arabic PDF to English
translator.translate_pdf("path/to/arabic-text.pdf", "ar", "en", "translated_to_english.txt")

# Translate English PDF to Arabic
translator.translate_pdf("path/to/english-text.pdf", "en", "ar", "translated_to_arabic.txt")

# Translate Arabic PDF to French
translator.translate_pdf("path/to/arabic-text.pdf", "ar", "fr", "translated_to_french.txt")

# Translate French PDF to Arabic
translator.translate_pdf("path/to/french-text.pdf", "fr", "ar", "translated_to_arabic.txt")

Requirements

  • Python 3.6+
  • PyMuPDF
  • Hugging Face Transformers

License

This code is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. You may not use this code for commercial purposes.

Contact

For any questions or issues, please contact Amin Boulouma.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

translatorar-0.1.7.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

translatorAR-0.1.7-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page