Skip to content

Saadellll/CodeAlpha_Language-Translation-Tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation


Language Translation Tool

This repository contains a Jupyter Notebook for building a language translation tool using Python. The tool utilizes the transformers library from Hugging Face and other necessary packages to perform translations between different languages.

Requirements

Before running the notebook, you need to install the following packages:

  • transformers
  • sentencepiece
  • langid

These can be installed using pip:

pip install transformers
pip install sentencepiece
pip install langid

Usage

To use the language translation tool, follow these steps:

Clone the Repository

Clone this repository to your local machine using the following command:

git clone https://github.com/your-username/language-translation-tool.git

Install the Necessary Packages

Ensure that you have all the required packages installed. You can run the cells in the notebook that contain the pip install commands, or manually install them as shown above.

Run the Notebook

Open the Language_Translation_Tool.ipynb notebook in Jupyter or any compatible environment and execute the cells sequentially.

Input and Translation

Follow the instructions in the notebook to input text and translate it into the desired language. The notebook contains code cells that guide you through the translation process.

Notebook Contents

The notebook contains the following sections:

  • Installation: Commands to install the required packages.
  • Code: The main code for language translation using Hugging Face's transformers.

Example Usage

Here is an example of how you can use the language translation tool:

Load the Translation Model

from transformers import MarianMTModel, MarianTokenizer

model_name = 'Helsinki-NLP/opus-mt-en-fr'
model = MarianMTModel.from_pretrained(model_name)
tokenizer = MarianTokenizer.from_pretrained(model_name)

Translate Text

def translate(text):
    inputs = tokenizer(text, return_tensors='pt', padding=True, truncation=True)
    translated_tokens = model.generate(**inputs)
    translated_text = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)
    return translated_text

text = "Hello, how are you?"
translated_text = translate(text)
print(translated_text)  # Output: "Bonjour, comment ça va ?"

Contributing

Contributions are welcome! If you have any suggestions or improvements, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published