Skip to main content

A utility for cleaning social media text.

Project description

SocialPreText

SocialPreText is a professional-grade Python utility for cleaning and preprocessing social media text. It is designed to prepare noisy data for Natural Language Processing (NLP) tasks by normalizing slang, contractions, and social media-specific tokens.


Installation

Install the package directly from PyPI using pip:

pip install socialpretext
Quick Start: The One-Step Solution
The clean_all function is the primary entry point. It runs a pre-defined sequence of cleaning steps to transform messy text into clean, usable English.

Python
from socialpretext import clean_all

raw_text = "OMG idk, @user! This update is lit 🔥 Check it out: [https://example.com](https://example.com) #tech"

# Run the default cleaning pipeline
cleaned = clean_all(raw_text)

print(cleaned)
# Output: "oh my god i do not know this update is amazing check it out"
API Reference & Function Syntaxes
Below are the functions available in the package. Each can be imported and used individually for granular control over your text processing.

The Main Pipeline
socialpretext.clean_all(text, pipeline_steps=None): The master function. Accepts a string and an optional list of steps to run. If no steps are provided, it runs the full default suite.

Content Expansion
socialpretext.expand_slang(text): Converts internet shorthand into formal English. Example: "idk" becomes "I do not know".

socialpretext.expand_contractions(text): Expands standard English contractions. Example: "it's" becomes "it is".

Token Removal
socialpretext.remove_urls(text): Strips out http, https, and www web links.

socialpretext.remove_mentions(text): Removes @username mentions from the text.

socialpretext.remove_hashtags(text): Removes #hashtags while keeping the rest of the sentence intact.

socialpretext.remove_punctuation(text): Strips all standard punctuation marks (e.g., !, ?, .).

Emoji Handling
socialpretext.remove_emojis(text): Completely deletes emoji characters from the string.

socialpretext.demojize(text): Replaces emojis with their text descriptions. Example: "🔥" becomes ":fire:".

Formatting
socialpretext.normalize_whitespace(text): Fixes formatting by replacing multiple spaces or newlines with a single space.

Author
Akash Goyal (akashpgoyal@gmail.com)

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

socialpretext-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

socialpretext-0.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file socialpretext-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for socialpretext-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5c89dedb85c496f76b70692aff3dbb922485ed52fe056ab5d390dc206e29c9b9
MD5 69e622198950ce94ce528d4bac740254
BLAKE2b-256 a3ab3892f72ea37e0a9db6a2d3fb2122bed2df0a32d45e75551617eb1da40c4b

See more details on using hashes here.

File details

Details for the file socialpretext-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for socialpretext-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 450b423702af671f54a317b6aae22a04ff1fc06b2b75f166dd7be20a077ddfb2
MD5 a852895ebfd092c813b9a4f62f8d577c
BLAKE2b-256 eb70a61e5acf3223faf4b9bd08622a88f644204a84d2a929aa4bc71ebaf8c89b

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