Skip to content

Powerful tools to perform NLP tasks on text messages with Python.

License

Notifications You must be signed in to change notification settings

UBC-MDS/DSCI524_Text_Analyzer_19

Repository files navigation

messageanalyzer

Documentation Status ci-cd codecov

messageanalyzer is a Python package designed for performing comprehensive Natural Language Processing (NLP) tasks on text messages. This package provides tools for sentiment analysis, keyword extraction, topic modeling, and language patterns detection, making it ideal for text mining and content analysis projects. Full documentation and tutorial is hosted on ReadtheDocs.

messageanalyzeris built for developers, data scientists, and researchers working in text mining, social media analysis, and customer feedback evaluation. Its easy-to-use design makes it a great fit for both NLP beginners who want straightforward solutions and experienced professionals seeking a quick, efficient way to draw insights from text data. Whether you’re analyzing customer reviews, survey responses, or social media content, this package offers a reliable tool to support business decisions, sentiment monitoring, and academic research in a practical and user-friendly way.

Installation

$ pip install messageanalyzer

Usage

Activate Python

Ensure you have Python installed on your system. To get started, activate it by running:

python

Here’s a sample text list that will be used in the examples below:

sample_text = [
    "Artificial intelligence and machine learning are transforming industries around the globe.",
    "The basketball team secured a thrilling victory in the final seconds of the game.",
    "Yoga and meditation are excellent for reducing stress and improving mental health.",
    "Exploring the hidden beaches of Bali is an unforgettable experience for any traveler.",
    "Quantum computing is expected to revolutionize data processing and cryptography."
]

You can now test the package with the examples below.

  • analyze_sentiment(messages: List[str], model: str = "Default") -> List[dict]:
    This function analyzes the sentiment of a list of given messages and returns the sentiment scores and labels for each message.

    Example:

    from messageanalyzer.sentiment_analysis import analyze_sentiment
    
    result = analyze_sentiment(sample_text)
    
    print(result)
  • topic_modeling(messages: List[str], n_topics: int = 5, n_words: int = 10, random_state: int = 123) -> dict:
    This function extracts topics from a list of messages and returns the words that represent the extracted topics using Nonnegative Matrix Factorization.

    Example:

    from messageanalyzer.topic_modeling import topic_modeling
    
    topics = topic_modeling(sample_text, n_topics=2, n_words=3)
    
    print(topics)
  • extract_keywords(messages: List[str], num_keywords: int = 5) -> list:
    This function extracts the top keywords from a list of messages.

    Example:

    from messageanalyzer.extract_keywords import extract_keywords
    
    keywords = extract_keywords(sample_text, num_keywords=3)
    
    print(keywords)
  • detect_language_patterns(messages: List[str], method: str = "language", n: int = 2, top_n: int = 5) -> list:
    This function detects language patterns such as detected languages, common n-grams, or character usage patterns from a list of messages.

    Example:

    from messageanalyzer.detect_language_patterns import detect_language_patterns
    
    patterns = detect_language_patterns(sample_text, method="language")
    
    print(patterns)

Running Test

Here is the code we’ve written for testing using pytest. Under the project root, run this following code :

poetry run pytest tests

Ecosystem Fit

messageanalyzer integrates into the Python NLP ecosystem by offering a simple yet powerful toolkit for analyzing text data. While other Python libraries like NLTK and spaCy provide extensive NLP functionalities, messageanalyzer focuses on making sentiment analysis, keyword extraction, and language pattern visualization more accessible and user-friendly.

For keyword extraction, packages like YAKE and RAKE-NLTK provide similar functionality. However, messageanalyzer combines these tasks into a unified and streamlined workflow.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

Dependencies

License

messageanalyzer was created by Quanhua Huang, Adrian Leung, Anna Nandar, Colombe Tolokin. It is licensed under the terms of the MIT license.

Credits

messageanalyzer was created with cookiecutter and the py-pkgs-cookiecutter template.

About

Powerful tools to perform NLP tasks on text messages with Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages