Skip to main content

Back Translator using Google translation API

Project description

Description

Back translation is the process of translating the text into a target language and then retranslating it into its source language. For example, translating the content from English to Swedish and retranslating it to English. In this process, the text retranslated to its source language from a target language might be a little different but conveys the same meaning or sentiment.

In the context of NLP, it's a very useful technique for text augmentation when the text data is not enough and we need more data to train a good model. If the sentence is not the same after the back translation then we'll keep the sentence. This technique is also known as Reverse Translation.

The library is designed to automate the process by taking the text data and converting it to some other language that can be chosen by the user or the library choose randomly and output the original and back-translated data.

Installation

$ pip install btranslation

Example

Basic Usage

Back translating a single sentence, using Russian. If the language is not given, then the library chooses a random language other than the initial one.
Note: The output is a Data Frame.

>>> import btranslation
>>> btrans = btranslation.back_translation('I drive the car very well', language = 'ru')
>>> print (btrans) 
                    Original     Back Translated Random Language
0  I drive the car very well  I drive very well.              ru

Advanced Usage (Bulk)

Back translating more than one sentence at a time.

>>> import btranslation
>>> btrans = btranslation.back_translation(['I drive the car very well', 'I can not ride a bicycle'], language = 'ru')
>>> print (btrans) 
                    Original     Back Translated Random Language
0  I drive the car very well  I drive very well.              ru
1  I can not ride a bicycle   I can't ride a bike             ru

Requirements

  • Python >= 3.0

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

btranslation-1.0.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

btranslation-1.0.1-py3-none-any.whl (3.6 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