Skip to main content

This is a Text Processing Package For NLP

Project description

Text Preprocessing Python Package

Course Link: Introduction to NLP

This Python package is created by Uditya Narayan Tiwari. It 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 text_preprocessing

Installation from GitHub

You can install this package from GitHub as follows:

pip install git+https://github.com/udityamerit/Text-Processing-Package-For-Natural-Language-Processing.git --upgrade --force-reinstall

Uninstall the Package

To uninstall the package, use the following command:

pip uninstall text_preprocessing

Requirements

You need to install these python packages.

python -m spacy download en_core_web_sm
spacy
textblob
beautifulsoup4
nltk
openpyxl
SpeechRecognition==3.10.4
pyaudio==0.2.14
PrettyTable
scikit-learn
wordcloud
lxml
pandas
numpy
matplotlib

How to Use the Package

1. Basic Text Preprocessing

Lowercasing Text

import text_preprocessing as tp

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

Expanding Contractions

import text_preprocessing as tp

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

Removing Emails

import text_preprocessing as tp

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

Removing URLs

import text_preprocessing as tp

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

Removing HTML Tags

import text_preprocessing as tp

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

Removing Special Characters

import text_preprocessing as tp

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

2. Advanced Text Processing

Lemmatization

import text_preprocessing as tp

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

Sentiment Analysis

import text_preprocessing as tp

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

Detecting and Translating Language

import text_preprocessing as tp
from googletrans import Translator

translator = Translator()
text = "Bonjour tout le monde"
lang = tp.detect_language(text, translator)
translated_text = tp.translate(text, 'en', translator)
print(f"Language: {lang}, Translated: {translated_text}")
# Output: Language: fr, Translated: Hello everyone

3. Feature Extraction

Word Count

import text_preprocessing as tp

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

Character Count

import text_preprocessing as tp

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

N-Grams

import text_preprocessing as tp

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

text = "I'm loving this NLP tutorial! Contact me at https://www.linkedin.com/in/uditya-narayan-tiwari-562332289/  Visit https://udityanarayantiwari.netlify.app/"
cleaned_text = tp.clean_text(text)
print(cleaned_text)
# Output: i am loving this nlp tutorial contact me at visit

One Short Feature Extraction

import text_preprocessing as tp

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

nlp_text_preprocessing-0.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

nlp_text_preprocessing-0.0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file nlp_text_preprocessing-0.0.1.tar.gz.

File metadata

  • Download URL: nlp_text_preprocessing-0.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for nlp_text_preprocessing-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cdaff067b35749d7a549d2c1dd86c84ed195bd7c43ddaf36e3730cd492a78d2e
MD5 bcd4733c87e308044becbbb84846420b
BLAKE2b-256 92682a521a2b75c9e64eea8a525289e42e8b3e3805caa601ecaa42295d809acb

See more details on using hashes here.

File details

Details for the file nlp_text_preprocessing-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nlp_text_preprocessing-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f71b847b3fd578f0b64eeb6aedfeff70b2c192dd951ac4ff7f7a11c012926ed
MD5 ec6598f04a0cab590be72644a0c394e5
BLAKE2b-256 b33c4ebb17651e94360ac3be5879cc87d75af13b9d7ae11c6292f376630b4638

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