A Python library for augmenting Korean text.
Project description
Textmentations
Textmentations is a Python library for augmenting Korean text. Inspired by albumentations. Textmentations uses the albumentations as a dependency.
Installation
pip install textmentations
A simple example
Textmentations provides text augmentation techniques implemented using the TextTransform, which inherits from the albumentations BasicTransform.
This allows textmentations to reuse the existing functionalities of albumentations.
import textmentations as T
text = "어제 식당에 갔다. 목이 너무 말랐다. 먼저 물 한 잔을 마셨다. 그리고 탕수육을 맛있게 먹었다."
rd = T.RandomDeletion(deletion_prob=0.3, min_words_per_sentence=1)
ri = T.RandomInsertion(insertion_prob=0.3, n_times=1)
rs = T.RandomSwap(n_times=3)
sr = T.SynonymReplacement(replacement_prob=0.3)
eda = T.Compose([rd, ri, rs, sr])
print(rd(text=text)["text"])
# 식당에 갔다. 목이 너무 말랐다. 먼저 물 잔을. 그리고 탕수육을 맛있게.
print(ri(text=text)["text"])
# 어제 최근 식당에 갔다. 목이 너무 말랐다. 먼저 물 한 잔을 마셨다 음료수. 그리고 탕수육을 맛있게 먹었다.
print(rs(text=text)["text"])
# 어제 갔다 식당에. 목이 너무 말랐다. 물 먼저 한 잔을 마셨다. 그리고 먹었다 맛있게 탕수육을.
print(sr(text=text)["text"])
# 과거 식당에 갔다. 목이 너무 말랐다. 먼저 소주 한 잔을 마셨다. 그리고 탕수육을 맛있게 먹었다.
print(eda(text=text)["text"])
# 식당에 어제 과거. 너무 말랐다. 상수 한 잔을 마셨다 맹물. 먹었다 그리고 맛있게.
List of augmentations
- AEDA
- BackTranslation
- RandomDeletion
- RandomDeletionSentence
- RandomInsertion
- RandomSwap
- RandomSwapSentence
- SynonymReplacement
References
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
textmentations-1.2.2.tar.gz
(178.0 kB
view hashes)
Built Distribution
textmentations-1.2.2-py3-none-any.whl
(180.7 kB
view hashes)
Close
Hashes for textmentations-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09ff111be4a717a2d6b54a785bea58b759c75b7631954f6c1980694c047b056b |
|
MD5 | f3d3b33025d755f8c80f419fbc1165f7 |
|
BLAKE2b-256 | 78c287f9b5b102f65155b38ba5e0bad98fd05ff3e60aa6aa40cb0ff614bcf9b5 |