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
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
Built Distribution
File details
Details for the file btranslation-1.0.1.tar.gz
.
File metadata
- Download URL: btranslation-1.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f87febbbee436283aa24a2b1af1b857e6439c39f146de5d39a0dc1f553258471 |
|
MD5 | 2a9e115f49c7c74444a397177120a53c |
|
BLAKE2b-256 | d82a6dedf50b8412a18c79bea704b6800162e5b73385b220a63c55f79cd412d1 |
File details
Details for the file btranslation-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: btranslation-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 373080f1f0d3e7e8124954f8750c67d4d7a83de7aaba0fb5f08a562664d7111d |
|
MD5 | a7f0d1970bf828e09b3a397e69df9dcf |
|
BLAKE2b-256 | 773205152374503ad7eed5e4adf5ac0cabbd0c13ff1fb6243a8d5801b716988b |