A comprehensive NLP library for text preprocessing, semantic analysis, and information extraction
Project description
NLPAP - NLP Analyzer Package
A comprehensive Natural Language Processing library that provides easy-to-use tools for text preprocessing, semantic analysis, and information extraction.
Features
Q1: Text Preprocessing & Representation
- ✅ Advanced tokenization using NLTK
- ✅ Stop word removal and text cleaning
- ✅ Lemmatization and stemming
- ✅ Bag-of-Words (BoW) representation
- ✅ TF-IDF calculation and analysis
- ✅ Vocabulary analysis and word frequency
Q2: Semantic Understanding & Language Modeling
- ✅ WordNet integration for synonyms, antonyms, and hypernyms
- ✅ N-gram language models (unigram, bigram, trigram)
- ✅ Laplace smoothing for probability estimation
- ✅ Next word prediction capabilities
- ✅ Semantic relationship extraction
Q3: Information Extraction & Sentiment Analysis
- ✅ Named Entity Recognition (NER)
- ✅ Rule-based sentiment analysis
- ✅ Word similarity analysis using co-occurrence
- ✅ Entity classification (Person, Organization, Location)
- ✅ Sentiment distribution analysis
Installation
pip install nlpap
Quick Start
from nlpap import ComprehensiveNLP
# Initialize the analyzer
nlp = ComprehensiveNLP()
# Sample texts (Mental Health domain example)
texts = [
"I feel overwhelmed with anxiety and stress lately. Need professional help.",
"The therapy sessions have been very helpful for my mental health recovery.",
"Depression affects many students during exam periods. Support is crucial."
]
# Run complete analysis
results = nlp.run_complete_analysis(texts)
# Access individual components
processed_data, tokens = nlp.preprocess_text(texts)
semantic_data = nlp.semantic_analysis(tokens)
entities, sentiments = nlp.information_extraction_and_sentiment(texts)
Detailed Usage
Text Preprocessing & Representation
# Initialize analyzer
nlp = ComprehensiveNLP()
# Preprocess texts
processed_data, all_tokens = nlp.preprocess_text(your_texts)
# The method returns:
# - Tokenized text
# - Filtered tokens (no stopwords/punctuation)
# - Lemmatized tokens
# - Stemmed tokens
# - BoW and TF-IDF representations
Semantic Analysis
# Analyze semantic relationships
semantic_data = nlp.semantic_analysis(tokens)
# Returns WordNet analysis:
# - Definitions
# - Synonyms and antonyms
# - Hypernyms (broader categories)
# - Language model with Laplace smoothing
Information Extraction & Sentiment
# Extract entities and analyze sentiment
entities, sentiments = nlp.information_extraction_and_sentiment(texts)
# Returns:
# - Named entities (Person, Organization, Location)
# - Sentiment classification (Positive, Negative, Neutral)
# - Word similarity analysis
Command Line Interface
After installation, you can use the command line interface:
# Analyze a single text
nlpap-analyze --text "Your text here"
# Analyze a file
nlpap-analyze --file path/to/your/textfile.txt
# Get help
nlpap-analyze --help
Dependencies
- nltk >= 3.7
- numpy >= 1.19.0
- pandas >= 1.2.0
- matplotlib >= 3.3.0
Educational Use
This library is designed for educational purposes and covers fundamental NLP concepts:
- Text Preprocessing: Learn how to clean and prepare text data
- Representation Methods: Understand BoW vs TF-IDF approaches
- Semantic Analysis: Explore word relationships using WordNet
- Language Modeling: Implement N-gram models with smoothing
- Information Extraction: Practice NER and sentiment analysis
- Word Embeddings: Analyze word similarity and relationships
Examples
Mental Health Text Analysis
from nlpap import ComprehensiveNLP
# Mental health related texts
mental_health_texts = [
"Feeling stressed about exams, need support and guidance.",
"Therapy has been helpful for managing anxiety effectively.",
"University counseling services provide excellent mental health support."
]
nlp = ComprehensiveNLP()
results = nlp.run_complete_analysis(mental_health_texts)
print("Analysis complete!")
print(f"Entities found: {results['entities']}")
print(f"Sentiments: {results['sentiments']}")
Custom Domain Analysis
# Use with your own domain-specific texts
your_texts = [
"Your domain-specific text here...",
"Another text for analysis...",
]
nlp = ComprehensiveNLP()
# Run individual analyses
processed_data, tokens = nlp.preprocess_text(your_texts)
semantic_data = nlp.semantic_analysis(tokens)
entities, sentiments = nlp.information_extraction_and_sentiment(your_texts)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this library in your research or projects, please cite:
@software{nlp_comprehensive_analyzer,
title={NLP Comprehensive Analyzer},
author={Your Name},
year={2024},
url={https://github.com/yourusername/nlp-comprehensive-analyzer}
}
Support
For support, please open an issue on GitHub or contact [your.email@example.com]
Perfect for students, researchers, and developers learning NLP fundamentals!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nlpap-1.0.1.tar.gz.
File metadata
- Download URL: nlpap-1.0.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1da664c87c11038c5e6c0911de2493c8e5ea70970cf56ae59bf6338f5929c3
|
|
| MD5 |
1d475050c5741cff4bb2c3423a455379
|
|
| BLAKE2b-256 |
c2858158dcc7e8c45194ccfde54291a092b8854e8994fbd9e9f41846cdb000dd
|
File details
Details for the file nlpap-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nlpap-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a1d7e119e6d0e36bb7fb07de77c2614c051fd3a3023bfafa57789588ff2924a
|
|
| MD5 |
b90fde76252837251d4a6d2844c3b17d
|
|
| BLAKE2b-256 |
35c056bf23d5a008d7165cadd80e3e10c5c4d7f3e1700b38fdf4f24e240a6991
|