Giter Site home page Giter Site logo

shhossain / banglatranslationkit Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 65 KB

BanglaTranslationKit is a open-source translation package for offline conversion between both Bengali and English languages (English to Bangla and Bangla to English)

License: Apache License 2.0

Python 100.00%
bangla-machine-translation bangla-translator machine-translation nlp python transformers translation bangla-ma

banglatranslationkit's Introduction

BanglaTranslationKit

BanglaTranslationKit is an open-source translation package for offline conversion between both Bengali and English languages (English to Bangla and Bangla to English)

Installation

pip install bntrans

Usage

You can use this package to translate any Bangla to English or English to Bangla.

from bntrans import Translator

translator = Translator(src="en", dest="bn")
translation = translator.translate("Hello world!")  #  ্যালো বিশ্ব!
print(translation)

Some Useful Methods

from bntrans import Translator

# You can tell the model to use cpu
translator = Translator(src="en", dest="bn", use_gpu=False)

# Specify a custom model (from huggingface.co/models or local path)
translator = Translator(model="mymodel")

# If the custom model doesn't have a maximum length, you can specify it. It is better to specify it as some models have wrong maximum length in their config.
translator = Translator(model="mymodel", max_length=512)

# You can also use the `generate` method to get raw output from the model
translator.generate("Hello world!")

Use Cloud Translation API (Free)

If you want to test the model without installing it, you can use the cloud translation API. Get a free Token from here (Read Token is enough) and use it like this:

from bntrans import Translator

translator = Translator(src="en", dest="bn", use_cloud=True, huggingface_token="YOUR_TOKEN")
translation = translator.translate("Hello world!")  #  ্যালো বিশ্ব!
print(translation)

Use in Command Line

You can also use this package in the command line. Just install it and run the following command:

bntrans "Hello world!"
usage: cli.py [-h] [-s SRC] [-d DEST] [-m MODEL] [-g GPU] [-l MAX_LENGTH] [-c USE_CLOUD] [-t HUGGINGFACE_TOKEN] text

Translate text from one language to another.

positional arguments:
  text                  Text to translate

options:
  -h, --help            show this help message and exit
  -s SRC, --src SRC     Source language (default: en)
  -d DEST, --dest DEST  Destination language (default: bn)
  -m MODEL, --model MODEL
                        Model to use for translation
  -g GPU, --gpu GPU     Whether to use GPU for translation (default: True)
  -l MAX_LENGTH, --max-length MAX_LENGTH
                        The maximum length of the model (default: None)
  -c USE_CLOUD, --use-cloud USE_CLOUD
                        Whether to use huggingface inference API (default: False)
  -t HUGGINGFACE_TOKEN, --huggingface-token HUGGINGFACE_TOKEN
                        Huggingface inference API token (default: None)

banglatranslationkit's People

Contributors

shhossain avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

c0debrain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.