Automatic data filtering library specialized in Korean data purification
Project description
Purism: Automatic data filtering library specialized in Korean data purification
Purify system
Summary
This repository is an automatic data filtering library specialized in Korean data purification.
How to use
Installation
Installation using pip
pip install purism
Quickstart
C4 dataset has "Clean" in its name, but it is NOT clean at all (especially the Korean subset). This is a code that performs additional filtering on the C4 dataset using this library.
from purism import PurifyConfig, UnicodeCleaner, UICleaner, TextCleaner, HarmfulWordsFilter, SpamWordsFilter
from datasets import load_dataset
from tqdm.auto import tqdm
# Load dataset
ds = load_dataset(
"allenai/c4",
"ko",
split="train",
streaming=True
).take(100)
# Load normalization techniques
norms = [
UnicodeCleaner("NFC"),
UICleaner(),
TextCleaner()
]
# Load filters
filters = [
HarmfulWordsFilter(3),
SpamWordsFilter(4)
]
# Load the previously defined filters and normalization techniques into PurifyConfig.
purifier = PurifyConfig(filters, norms)
passed = []
filtered = []
for text in tqdm(ds, desc="Filtering...", total=100):
result = purifier.purify(text["text"]) # Apply the normalization techniques and filters loaded in PurifyConfig.
if result["passed"]:
passed.append(result["raw_text"])
else:
filtered.append(result["raw_text"])
print("=" * 200)
# Uncensored corpora
for i in range(10):
print(f"Sample {i + 1} (passed): {passed[i]}")
print("=" * 200)
# Censored corpora
for i in range(10):
print(f"Sample {i + 1} (filtered): {filtered[i]}")
print("=" * 200)
You can see that corpus marked as "passed" are better than corpus marked as "filtered".
API
This library contains many more types of filters in addition to the two mentioned earlier. If you would like to see more features, please visit this page.
Limitations
- This library can accurately filter only Korean text. Modification of the source code is required to use other languages.
- This library is not always accurate. It can filter out non-harmful corpora, but may fail to filter out some harmful corpora.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file purism-1.0.2.tar.gz.
File metadata
- Download URL: purism-1.0.2.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0538b3f5db87e984f55b3e88383f49a12c42591b311171e21d775d87cfa9beae
|
|
| MD5 |
5b8f64c8fa304a6d2bd42ecf9ee589a2
|
|
| BLAKE2b-256 |
132ef114ab8d8cfc0929641e9055c16ed1ba944adfe57a6cd41a5af2080d823c
|
File details
Details for the file purism-1.0.2-py3-none-any.whl.
File metadata
- Download URL: purism-1.0.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff212b997fdbbe08f2f854720ef5925f655cfeca16ee5b7f8d00a1c565fd61a
|
|
| MD5 |
67d61e06d1b5b186ae97c4120b5af49e
|
|
| BLAKE2b-256 |
678472f546061caf40ce4a70dcd996730aad60155be3119ab252c99eee6d54f8
|