This is a simple Python project that performs two main tasks:
- Translates text: Uses the Google Translate API to translate text from any language to a specified target language.
- Corrects grammatical errors: Uses the LanguageTool library to identify and correct grammar and spelling mistakes in the translated text.
- Supports translation to multiple languages.
- Corrects grammatical errors in the translated text.
- Easy to use and extend.
Before you start, ensure you have the following installed:
- Python 3.x
- pip (Python package installer)
-
Clone this repository or download the code:
git clone https://github.com/Dev-wael1/Text-Translator.git cd Text-Translator
-
Install the required Python libraries:
pip install googletrans==4.0.0-rc1 language-tool-python
-
Import the required libraries and functions:
import googletrans import language_tool_python
-
Use the provided functions to translate and correct text. Here’s an example:
input_text = "J'aime manger des pomme. il est trés bon" target_language = 'en' # Translate to English result = translate_and_correct(input_text, target_language) print("Translated and Corrected Text:", result)
Input (French):
J'aime manger des pomme. il est trés bon
Output (English and corrected):
I like eating apples. It is very good.
Translates the given text into the target language using Google Translate.
- text: The input text to be translated.
- target_language: The language to translate the text into (default: English
'en'
).
Corrects any grammatical errors in the given text using LanguageTool.
- text: The input text to be checked for grammar errors.
A combination of translation and error correction. It first translates the text and then applies grammar corrections.
- text: The input text.
- target_language: The language to translate the text into (default: English
'en'
).
Contributions are welcome! Feel free to submit a pull request or open an issue if you have any suggestions or improvements.
This project is open source and available under the MIT License.