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

View in Korean

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.

import os
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(1000)

# Load normalization techniques
norms = [
    UnicodeCleaner("NFC"),
    UICleaner(),
    TextCleaner()
]

# Load filters
fast_filters = [
    HarmfulWordsFilter(3),
    SpamWordsFilter(4),
    DedupFilter()
]

heavy_filters = [
    PPLFilter()
]

# Load the previously defined filters and normalization techniques into PurifyConfig.
purifier = PurifyConfig(
    norms,
    fast_filters,
    heavy_filters
)

all_list = []

for text in ds:
    all_list.append(ds["text"])

result = purifier.parallel_purify(all_list, os.cpu_count()) # Apply the normalization technique and filters loaded in PurifyConfig.

print("=" * 200)

for i in range(20):
    print(f"Sample {i + 1} (passed: {result[i]["passed"]}): {result[i]["text"]}")
    print("=" * 200)

You can see that corpus marked as "passed: True" are better than corpus marked as "passed: False".

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-2.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

purism-2.0.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: purism-2.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for purism-2.0.0.tar.gz
Algorithm Hash digest
SHA256 dbc35cec05fbf5de5e05af65c16fc913f5896f6562daefad14a755822cfb0b68
MD5 c127c051129ae16570a858460239fe7d
BLAKE2b-256 371f568daf087c752c8859a76a355bd0a13cabc8cdb827b86bdee208e497fe4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: purism-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for purism-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4a0253fc88382518ab6417c194351f65aad5489567fdb0191dd3b61856981d4
MD5 40ed7f05a2b0ef5aaf4bcfbbd4d02cba
BLAKE2b-256 e43bc5199ccf24d22ebb233b95cbd8d86d2962d0ceae8ec18b81bf0cbdf1fabb

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