Skip to main content

Text Preprocessing Library

Project description

nlpprepkit

nlpprepkit is a Python library for text preprocessing, designed to simplify and accelerate the preparation of text data for natural language processing (NLP) tasks.

Features

  • Text Cleaning: Remove extra whitespace, special characters, emojis, HTML tags, URLs, numbers, and social tags.
  • Contraction Expansion: Expand common English contractions (e.g., "don't" → "do not").
  • Unicode Normalization: Normalize text to ASCII representation.
  • Pipeline Support: Create customizable pipelines for sequential text processing.
  • Profiling: Measure the execution time of each step in the pipeline.
  • Caching: Avoid redundant processing with built-in caching.
  • Parallel Processing: Process large text datasets efficiently.

Installation

Install the library using pip:

pip install nlpprepkit

Or install from source:

git clone https://github.com/vnniciusg/nlpprepkit.git
cd nlpprepkit
pip install -e .

Quick Start

Using the Pipeline

from nlpprepkit.pipeline import Pipeline

# Define a custom processing step
def lowercase(text):
    return text.lower()

# Create a pipeline and add the step
pipeline = Pipeline()
pipeline.add_step(lowercase)

# Process text
result = pipeline.process("This is a TEST.")
print(result)  # Output: "this is a test."

Text Cleaning Functions

from nlpprepkit.functions import remove_extra_whitespace, remove_special_characters

text = "This   is   a   test!!!"
cleaned_text = remove_extra_whitespace(text)
print(cleaned_text)  # Output: "This is a test!!!"

cleaned_text = remove_special_characters(cleaned_text)
print(cleaned_text)  # Output: "This is a test"

Expanding Contractions

from nlpprepkit.functions import expand_contractions

text = "I'm going to the store."
expanded_text = expand_contractions(text)
print(expanded_text)  # Output: "I am going to the store."

Running Tests

To run the tests, use pytest:

pytest

Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue on GitHub.

License

This project is licensed under the MIT License.

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

nlpprepkit-1.2.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

nlpprepkit-1.2.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file nlpprepkit-1.2.1.tar.gz.

File metadata

  • Download URL: nlpprepkit-1.2.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for nlpprepkit-1.2.1.tar.gz
Algorithm Hash digest
SHA256 6819d9a28a88921ea71ba9f6ecb94c96467194433f5f56d6c87cc9f62a7a05fc
MD5 f4418f93cbafb229d548663708aed10a
BLAKE2b-256 7d52dcf5187429981bccc86fd20f4662b1ab649bdf55877eb753177ac801e26e

See more details on using hashes here.

File details

Details for the file nlpprepkit-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: nlpprepkit-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for nlpprepkit-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2145faca1f586147af063e83d8b35e9b9f08a30bce0004da95de499e06492f
MD5 deba92dd90b4ef330499aed00dd49030
BLAKE2b-256 eb7893939d6259e6f2946edd8d2569eee921e16e7ce1c08363f0732c50e4afb7

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