Skip to main content

A robust text cleaning library for Python

Project description

textclean

A multi-language (Python, JavaScript) text cleaning library with CLI support.

Features

  • Trim leading/trailing whitespace
  • Collapse multiple spaces
  • Normalize newlines
  • Remove zero-width Unicode chars
  • Remove non-breaking spaces
  • Preserve emojis
  • Preserve language accents

Usage

JavaScript

import { clean } from "textclean";

const text = "  Hello   World! \u200B ";
const cleaned = clean(text, {
  trim: true,
  collapseSpaces: true,
});

console.log(cleaned); // "Hello World!"

Python

from textclean import clean

text = "  Hello   World! \u200B "
cleaned = clean(text, options={
    "trim": True,
    "collapse_spaces": True
})

print(cleaned) # "Hello World!"

CLI

# Process a file
textclean input.txt > output.txt

# Pipe from stdin
echo "  Hello   World!  " | textclean

Structure

  • core/js: JavaScript implementation and CLI
  • core/python: Python implementation and CLI

AI Assistance Disclaimer

This project was developed with assistance from AI/LLMs (including GitHub Copilot, ChatGPT, and related tools), supervised by humans who occasionally knew what they were doing.

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

textclean_py-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

textclean_py-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file textclean_py-0.1.0.tar.gz.

File metadata

  • Download URL: textclean_py-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for textclean_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8dae62dc62b5b5174a03a329241ef19d50fb725826a9e60c6d54bd05935c222a
MD5 11298d599278390db61e9d19ee9d21c3
BLAKE2b-256 c0da7a2016ae9b65e67c6d654eb678251594182a96662c3f5fea9b760fd498fa

See more details on using hashes here.

File details

Details for the file textclean_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: textclean_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for textclean_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5e9b336c49ed482d1de4bf5ad5ab8da8c8817f3a34748196aaf148bfd61d990
MD5 5dc4993d1498d9b9662778aaf651437a
BLAKE2b-256 5e6ed17ec43d567ea991920f6285075803ff3e9a511b47851986cbd3b87687f0

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