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
- Hugging Face Transformers for providing pre-trained translation models.
- PyMuPDF for PDF text extraction.
Project details
Release history Release notifications | RSS feed
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.4.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for translatorAR-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd4bac8fd4a60e40357cc5f008284c5050341984aabdee98706b7cdfdabd9553 |
|
MD5 | 5b53996b7f86c9a9676b2991b569cbb8 |
|
BLAKE2b-256 | 70cd547a8ea4386856be2833bf1c62f5b0e3dda5d9bf5b5bf2175f736099b445 |