Skip to main content

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:

  1. Text Preprocessing: Learn how to clean and prepare text data
  2. Representation Methods: Understand BoW vs TF-IDF approaches
  3. Semantic Analysis: Explore word relationships using WordNet
  4. Language Modeling: Implement N-gram models with smoothing
  5. Information Extraction: Practice NER and sentiment analysis
  6. 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


Download files

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

Source Distribution

nlpap-1.0.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

nlpap-1.0.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file nlpap-1.0.0.tar.gz.

File metadata

  • Download URL: nlpap-1.0.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nlpap-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f17238494bdc53563f81ea70c7df3ea2693e11f0e0ceb43be13ec937790861f5
MD5 229f77f171e69de11e5887f74999925a
BLAKE2b-256 60df6ea2c6cdce2244ab42902aea44143bdf1792d5392f49d1b028d6b06707c1

See more details on using hashes here.

File details

Details for the file nlpap-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nlpap-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nlpap-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac20c5003e88541f8a84b81b2d6d816765ef56889b8dd3b927fd005516ddf6d3
MD5 86111d680a2ea7cac6aa8ffc3d2b15a9
BLAKE2b-256 8c7232b2ee056d9289a75fe9f2bcba218c7dadfaebbad19acf396fe67e314df3

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