Skip to main content

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

purism-1.0.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

purism-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file purism-1.0.1.tar.gz.

File metadata

  • Download URL: purism-1.0.1.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

Hashes for purism-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6ae5cf9dbe7b93a9598b35c0e7c3d098f6b7b9292ccaf03f68ff80ce08443a6c
MD5 02bfec808293d6bf38264728b2d522c4
BLAKE2b-256 f82cdc176ef7ce34e0f1628de5a47fd8239938fe7f3ebacc6ab8f78a9a3242fe

See more details on using hashes here.

File details

Details for the file purism-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: purism-1.0.1-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

Hashes for purism-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c90575b7ad7cc6416cc406a7adcb9a6fa56968bcb01e487ada19d8eeba18087a
MD5 45d02976e4ce99b28e5ba3dfb77897d7
BLAKE2b-256 cb99ad9b67b00233ce0fdcf170b423bd07a4fb687366c3f204df0ff085e77fcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page