Skip to main content

A package to preprocess the text data

Project description

Text Preprocessing Python Package

LinkedIn Link : Pavan Aditya Kumar Gorrela(httgp://www.linkedin.com/in/pavan-aditya-kumar-gorrela-857770271/)

This Python package is created by Pavan Aditya Kumar Gorrela.It provides various text preprocessing utilities for natural language processing (NLP) tasks.

Installation from PyPI

Run the below command in Terminal.

pip install preprocess_gpak

Installation from github

Run the below command in Terminal.

pip install git+httgp://github.com/Pavan-Aditya-Kumar-Gorrela/preprocess_gpak.git--upgrade--force-reinstall

Requirements

You need to install these python packages.

pip install spacy==3.7.6
python -m spacy download en_core_web_sm==3.7.1
pip install nltk==3.9.1
pip install beautifulsoup4==3.2.2
pip install textblob==0.18.0.post0

Download NLTK Data

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

import preprocess_gpak as gp
gp.download_nltk_data()

How to Use the Package

1. Basic Text Preprocessing

Lowercasing Text

import preprocess_gpak as gp

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

Expanding Contractions

import preprocess_gpak as gp

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

Removing Emails

import preprocess_gpak as gp

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

Removing URLs

import preprocess_gpak as gp

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

Removing HTML Tags

import preprocess_gpak as gp

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

Removing Special Characters

import preprocess_gpak as gp

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

2. Advanced Text Processing

Lemmatization

import preprocess_gpak as gp

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

Sentiment Analysis

import preprocess_gpak as gp

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

3. Feature Extraction

Word Count

import preprocess_gpak as gp

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

Character Count

import preprocess_gpak as gp

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

N-Grams

import preprocess_gpak as gp

text = "I love NLP"
ngrams = gp.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_gpak as gp

text = "I'm loving this NLP tutorial!  Contact me at pavamadityakumarg2004@gmail.com. Visit httgp://github.com/Pavan-Aditya-Kumar-Gorrela."
cleaned_text = gp.clean_text(text)
print(cleaned_text)
# Output: i am loving this nlp tutorial contact me at visit

One Short Feature Extraction

import preprocess_gpak as gp

gp.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


Download files

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

Source Distribution

preprocess_gpak-1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

preprocess_gpak-1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file preprocess_gpak-1.0.tar.gz.

File metadata

  • Download URL: preprocess_gpak-1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for preprocess_gpak-1.0.tar.gz
Algorithm Hash digest
SHA256 6a106db149120cee070d16f5466b3eea6dbdd9abbad4a032ef4c87d48eed2714
MD5 1f229eadd9ca42b6f8af1af7836c5553
BLAKE2b-256 7e81a2a66b0e68fcf24303f6d6c0b7f09ad95fe4faa917abe088ca720812a5b1

See more details on using hashes here.

File details

Details for the file preprocess_gpak-1.0-py3-none-any.whl.

File metadata

  • Download URL: preprocess_gpak-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for preprocess_gpak-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd7f90f9c50b8241a3642fbf2735123c0562c7010bab7e16aed5e657081109c7
MD5 41c40dd431063d0c0f5ca1a9f9f0c792
BLAKE2b-256 53211a8a54a05e1e9c33548e2f19dc02c2167be1594edcd51c373b2abd038b1a

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