bnaug (Bangla Text Augmentation)
bnaug is a text augmentation tool for Bangla text.
Installation
pip install bnaug
- Dependencies
- pytorch >=1.7.0
Demo Notebook
Necessary Model Links
Sentence Augmentation
Token Replacement
-
Mask generation based augmentation
from bnaug.sentence import TokenReplacement tokr = TokenReplacement() text = "আমি ঢাকায় বাস করি।" output = tokr.masking_based(text, sen_n=5)
-
Word2Vec based augmentation
from bnaug.sentence import TokenReplacement tokr = TokenReplacement() text = "আমি ঢাকায় বাস করি।" model = "msc/bangla_word2vec/bnwiki_word2vec.model" output = tokr.word2vec_based(text, model=model, sen_n=5, word_n=5) print(output)
-
Glove based augmentation
from bnaug.sentence import TokenReplacement tokr = TokenReplacement() text = "আমি ঢাকায় বাস করি।" vector = "msc/bn_glove.300d.txt" output = tokr.glove_based(text, vector_path=vector, sen_n=5, word_n=5) print(output)
Back Translation
Back translation based augmentation first translate Bangla sentence to English and then again translate the English to Bangla.
from bnaug.sentence import BackTranslation
bt = BackTranslation()
text = "বাংলা ভাষা আন্দোলন তদানীন্তন পূর্ব পাকিস্তানে সংঘটিত একটি সাংস্কৃতিক ও রাজনৈতিক আন্দোলন। "
output = bt.get_augmented_sentences(text)
print(output)
Text Generation
- Paraphrase generation
from bnaug.sentence import TextGeneration
tg = TextGeneration()
text = "বিমানটি যখন মাটিতে নামার জন্য এয়ারপোর্টের কাছাকাছি আসছে, তখন ল্যান্ডিং গিয়ারের খোপের ঢাকনাটি খুলে যায়।"
output = tg.parapharse_generation(text)
print(output)
Random Augmentation
-
Random remove part and generate new sentence
At present it's removing word, stopwords, punctuations, numbers and generate new sentences
from bnaug.sentence import RandomAugmentation raug = RandomAugmentation() sentence = "আমি ১০০ বাকি দিলাম" output = raug.random_remove(sentence) print(output)
or apply individually
from bnaug import randaug text = "১০০ বাকি দিলাম" output = randaug.remove_digits(text) print(output) text = "১০০! বাকি দিলাম?" output = randaug.remove_punctuations(text) print(output) text = "আমি ১০০ বাকি দিলাম" randaug.remove_stopwords(text) print(output) text = "আমি ১০০ বাকি দিলাম" randaug.remove_random_word(text) print(output) text = "আমি ১০০ বাকি দিলাম" randaug.remove_random_char(text) print(output)
Inspired from
Metadata
Release files for bnaug 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bnaug-1.1.2.tar.gz | 5.1 kB | Without provenance | Details for bnaug-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bnaug-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for bnaug-1.1.2-py3-none-any.whl |
Total release size: 9.9 kB
Release files / bnaug-1.1.2.tar.gz
| Download URL | bnaug-1.1.2.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c524078fceb1b2edbef5b0a7e7a4cccc912333e6d5248412ef1a59a6ee18d2f9
|
|
BLAKE2b-256 checksum How to use checksums |
15efba3f00852c102db73029c8cec8ae96c10a2cada28a8b2db4610b114db91c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / bnaug-1.1.2-py3-none-any.whl
| Download URL | bnaug-1.1.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb069f70fa0f7af3fcf2f58d5a9d6f1cf8f0c18fe3b1030630bb75795e0e9fe5
|
|
BLAKE2b-256 checksum How to use checksums |
198a7a0e8389bec7c8694270d13979d93e946261f2497465af5c9fc6f53782c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for bnaug 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.