Skip to main content

A package that automates text preprocessing

Project description

Text Preprocessing Toolkit (TPTK)

Build Status
A comprehensive Python library to streamline text preprocessing tasks, designed for NLP projects.


Table of Contents

  1. Overview
  2. Features
  3. Installation
  4. Getting Started
  5. Examples
  6. Contributing
  7. License
  8. Contact

Overview

The Text Preprocessing Toolkit (TPTK) is a Python library designed to simplify the preprocessing of raw text data. Whether you're working on an NLP project, a machine learning pipeline, or simply cleaning text data, TPTK provides an easy-to-use, customizable solution for common text preprocessing needs.


Features

  • Text Cleaning:
    • Remove punctuation, special characters, HTML tags, and URLs.
  • Normalization:
    • Convert text to lowercase, handle diacritics, and normalize Unicode.
  • Tokenization:
    • Split text into words or sentences.
  • Stopword Removal:
    • Remove common stopwords or use a custom list.
  • Lemmatization & Stemming:
    • Normalize words to their base form.
  • Spell Correction:
    • Automatically fix spelling errors.
  • Custom Pipelines:
    • Select and order the preprocessing steps to suit your needs.

Installation

Install the package using pip:

pip install TPTK

Alternatively, install directly from the GitHub repository:

pip install git+https://github.com/Gaurav-Jaiswal-1/Text-Preprocessing-Toolkit.git

Getting Started

Basic Usage

Import the library and start preprocessing:

from TextPreprocessingToolkit.tptk import TextPreprocessor

# Initialize the preprocessor
preprocessor = TextPreprocessor()

# Sample text
text = "This is <b>sample</b> text with a URL: https://example.com and speelingg errors."

# Apply preprocessing
processed_text = preprocessor.preprocess(text)

print("Processed Text:", processed_text)

Custom Preprocessing

You can define a custom pipeline for your preprocessing needs:

custom_steps = [
    "lowercase",
    "remove_url",
    "remove_punctuation",
    "correct_spellings"
]

processed_text = preprocessor.preprocess(text, steps=custom_steps)
print("Custom Processed Text:", processed_text)

Examples

Analyze Text Data

You can pass a list of texts and get an overview of their structure:

texts = [
    "Text example 1 with HTML tags <b>bold</b>!",
    "Another text with a URL: https://example.com.",
    "Missspelled word is heree!"
]

preprocessor.head(texts)

Preprocess a Dataset

TPTK works seamlessly with pandas:

import pandas as pd
from TextPreprocessingToolkit.tptk import TextPreprocessor

# Sample data
data = {"texts": ["Hello, <b>world</b>!", "Check out https://example.com.", "Thiss is a missspelled text."]}
df = pd.DataFrame(data)

# Initialize the preprocessor
preprocessor = TextPreprocessor()

# Apply preprocessing to a column
df["processed_texts"] = df["texts"].apply(preprocessor.preprocess)
print(df)

Contributing

We welcome contributions to improve the toolkit! To contribute:

  1. Fork the repository.
  2. Clone your fork and create a new branch:
    git checkout -b feature-branch-name
    
  3. Make your changes and commit:
    git commit -m "Describe your changes"
    
  4. Push your changes:
    git push origin feature-branch-name
    
  5. Create a Pull Request (PR) to the main repository.

For detailed contribution guidelines, check the CONTRIBUTING.md file.


License

This project is licensed under the MIT License. See the LICENSE file for more details.


Contact

For questions or support, feel free to reach out:

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

tptk-0.0.6.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

TPTK-0.0.6-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file tptk-0.0.6.tar.gz.

File metadata

  • Download URL: tptk-0.0.6.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for tptk-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ba4151e3308853dffa44cc11b1377035ec62ac8b71a356c8d2c4ca76627f1688
MD5 c3795e65e7dd8b40a3544b3dbb832b4a
BLAKE2b-256 27f64bb5c3e75a6bf15b01693ed25cccad7ea7906d169ad51229ad97e3c020b7

See more details on using hashes here.

File details

Details for the file TPTK-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: TPTK-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for TPTK-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 10c43ba83ec2521587f572eae8b1f7cca96061ee4aee052657dcd1d6e4f3b6b6
MD5 5c403e53697369bb0b3979aae32f95ee
BLAKE2b-256 655fe635938ebbb86c5af9dc1710f4793aa31b571cd9fc61e35b9e5b2bed60d6

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