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.5.tar.gz (6.5 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.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tptk-0.0.5.tar.gz
  • Upload date:
  • Size: 6.5 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.5.tar.gz
Algorithm Hash digest
SHA256 9d44f07b8fb19c36c5f8c6a58ee77e33e72149d922b817a56fe304c4cda852a6
MD5 56d60607bb22710d3d36b6f8a3999b3b
BLAKE2b-256 198a4ecadbac12117963f1f4c8d606bc11f4566ef5b652753a2264ab4fb61df9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: TPTK-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b154bb5e4d45fb302fe0c2c146bdb8c6c1af14edb27409d5b31e359bea097d9b
MD5 b605a71318ba624f6d42bd60679cc492
BLAKE2b-256 1aa9cdf4d184575e0b7a05e7b68319b7d73fe528f9fa07e2a6e253e712a1826a

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