Skip to main content

This is a text preprocessing package

Project description

Text Preprocessing Python Package

This Python package provides various text preprocessing utilities for natural language processing (NLP) tasks.

Installation from PyPi

You can install this package using pip as follows:

pip install preprocess_jbros

Installation from GitHub

You can install this package from GitHub as follows:

pip install git+https://github.com/jobigutenburg02/preprocess_jbros.git --upgrade --force-reinstall

Uninstall the Package

To uninstall the package, use the following command:

pip uninstall preprocess_jbros

Requirements

You need to install these python packages.

pip install spacy==3.8.14
python -m spacy download en_core_web_sm==3.8.0
pip install nltk==3.9.4
pip install beautifulsoup4==4.15.0
pip install textblob==0.18.0.post0
pip install deep-translator==1.11.4
pip install langdetect==1.0.9

Download NLTK Data

If you are using this package first time then You need to download NLTK data as follows:

import preprocess_jbros as ps
ps.download_nltk_data()

How to Use the Package

1. Basic Text Preprocessing

Lowercasing Text

import preprocess_jbros as ps

text = "HELLO WORLD!"
processed_text = ps.to_lower_case(text)
print(processed_text)  # Output: hello world!

Expanding Contractions

import preprocess_jbros as ps

text = "I'm learning NLP."
processed_text = ps.contraction_to_expansion(text)
print(processed_text)  # Output: I am learning NLP.

Removing Emails

import preprocess_jbros as ps

text = "Contact me at example@example.com"
processed_text = ps.remove_emails(text)
print(processed_text)  # Output: Contact me at 

Removing URLs

import preprocess_jbros as ps

text = "Check out https://example.com"
processed_text = ps.remove_urls(text)
print(processed_text)  # Output: Check out

Removing HTML Tags

import preprocess_jbros as ps

text = "<p>Hello World!</p>"
processed_text = ps.remove_html_tags(text)
print(processed_text)  # Output: Hello World!

Removing Special Characters

import preprocess_jbros as ps

text = "Hello @World! #NLP"
processed_text = ps.remove_special_chars(text)
print(processed_text)  # Output: Hello World NLP

2. Advanced Text Processing

Lemmatization

import preprocess_jbros as ps

text = "running runs"
processed_text = ps.lemmatize(text)
print(processed_text)  # Output: run run

Sentiment Analysis

import preprocess_jbros as ps

text = "I love programming!"
sentiment = ps.sentiment_analysis(text)
print(sentiment)  # Output: Sentiment(polarity=0.5, subjectivity=0.6)

Detecting and Translating Language

from deep_translator import GoogleTranslator
from langdetect import detect

text = "Bonjour tout le monde"
lang = detect(text)
translated_text = GoogleTranslator(source=lang, target="en").translate(text)
print(f"Language: {lang}, Translated: {translated_text}")
# Output: Language: fr, Translated: Hello everyone

3. Feature Extraction

Word Count

import preprocess_jbros as ps

text = "I love NLP."
count = ps.word_count(text)
print(count)  # Output: 3

Character Count

import preprocess_jbros as ps

text = "I love NLP."
count = ps.char_count(text)
print(count)  # Output: 9

N-Grams

import preprocess_jbros as ps

text = "I love NLP"
ngrams = ps.n_grams(text, n=2)
print(ngrams)  # Output: [('I', 'love'), ('love', 'NLP')]

4. Full Example: Cleaning Text

Here’s an example of how you might use several functions together to clean text data:

import preprocess_jbros as ps

text = "I'm enjoying NLP! Contact me at jbros2513@gmail.com. Visit https://jbros.com."
cleaned_text = clean_text(text)
print(cleaned_text)
# Output: I be enjoy nlp contact I at   visit

One Short Feature Extraction

import preprocess_jbros as ps

ps.extract_features("I love NLP")

Notes

  • Be cautious when using heavy operations like lemmatize and spelling_correction on very large datasets, as they can be time-consuming.
  • The package supports custom cleaning and preprocessing pipelines by using these modular functions together.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

preprocess_jbros-0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

preprocess_jbros-0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file preprocess_jbros-0.1.tar.gz.

File metadata

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

File hashes

Hashes for preprocess_jbros-0.1.tar.gz
Algorithm Hash digest
SHA256 6d6aebffe27abdffe1f837c91fef33115e6610196bf0fe6af39b23542278905b
MD5 50a9b78f16e555dd0e87fa407b41f6ad
BLAKE2b-256 90d75e2b3cd654385059c78164932bebc075e25b4b0723cd526d94629ab17317

See more details on using hashes here.

File details

Details for the file preprocess_jbros-0.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for preprocess_jbros-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8fc07ecf4f3e8cbb19877153da5c46117ba22732b963975b943ebe1f427d5130
MD5 03b097ecd7f622e3c7af0558482f776b
BLAKE2b-256 8487d96bfb681be8439656fc2799d9a5ee84ea2e594de1426aa554690aeba172

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