Skip to main content

A package for text analysis and visualization

Project description

TextInsights

Python Tests License: MIT Python Version

A Python package for text analysis and visualization. TextInsights provides simple yet powerful tools for analyzing text data, calculating statistics, and understanding content insights.

Installation

pip install textinsights

Quick Start

from textinsights import TextAnalyzer

# Create an analyzer with your text
text = "TextInsights makes text analysis easy and efficient!"
analyzer = TextAnalyzer(text)

# Get basic statistics
print(f"Word count: {analyzer.word_count()}")
# Output: Word count: 7

print(f"Unique words: {len(analyzer.unique_words())}")
# Output: Unique words: 7

print(f"Average word length: {analyzer.avg_word_length():.2f}")
# Output: Average word length: 6.71

Features

  • Text Analysis: Word counts, unique words, average word length
  • Statistical Analysis: Word frequency, distribution metrics
  • Sentiment Analysis: Basic sentiment scoring
  • Easy API: Simple, intuitive interface for text processing
  • Extensible: Build your own analyzers on top of the framework

Usage Examples

Basic Text Analysis

from textinsights import TextAnalyzer

text = """Python is a programming language that lets you work quickly and
integrate systems more effectively. Python is easy to learn, yet powerful
and versatile. Many developers love Python for its simplicity and readability."""

analyzer = TextAnalyzer(text)

# Basic statistics
print(f"Word count: {analyzer.word_count()}")
print(f"Unique words: {len(analyzer.unique_words())}")
print(f"Average word length: {analyzer.avg_word_length():.2f}")

# Output:
# Word count: 30
# Unique words: 26
# Average word length: 4.77

Word Frequency Analysis

from textinsights import word_frequency

text = "Python is amazing. Python is versatile. Python is Python."
frequencies = word_frequency(text)

# Get the most common words
print(frequencies.most_common(3))
# Output: [('python', 3), ('is', 3), ('amazing', 1)]

# Check frequency of a specific word
print(f"Frequency of 'python': {frequencies['python']}")
# Output: Frequency of 'python': 3

Sentiment Analysis

from textinsights import sentiment_score

# Using default positive/negative word lists
text1 = "I love this product. It's excellent and amazing!"
score1 = sentiment_score(text1)
print(f"Sentiment score 1: {score1:.2f}")
# Output: Sentiment score 1: 1.00

text2 = "This is terrible and disappointing. I hate it."
score2 = sentiment_score(text2)
print(f"Sentiment score 2: {score2:.2f}")
# Output: Sentiment score 2: -1.00

text3 = "The product has good features but also some bad aspects."
score3 = sentiment_score(text3)
print(f"Sentiment score 3: {score3:.2f}")
# Output: Sentiment score 3: 0.00

# Using custom word lists
positive_words = ['efficient', 'fast', 'innovative']
negative_words = ['slow', 'complicated', 'buggy']

text4 = "The system is efficient and fast, but slightly complicated."
score4 = sentiment_score(text4, positive_words, negative_words)
print(f"Custom sentiment score: {score4:.2f}")
# Output: Custom sentiment score: 0.33

Project Structure

textinsights/
├── textinsights/
│   ├── __init__.py
│   ├── analyzer.py
│   ├── stats.py
│   └── visualizer.py
├── tests/
│   ├── __init__.py
│   ├── test_analyzer.py
│   └── test_stats.py
├── setup.py
├── README.md
├── LICENSE
└── .gitignore

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/ksg-dev/textinsights.git
cd textinsights

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -r requirements-dev.txt

# Install package in development mode
pip install -e .

Running Tests

# Run all tests
pytest

# Run tests with coverage report
pytest --cov=textinsights

Contributing

Contributions are welcome! Please check out our contributing guidelines for details on how to submit pull requests, report issues, and suggest improvements.

Roadmap

  • Add advanced NLP features (tokenization, lemmatization)
  • Implement text classification capabilities
  • Add more visualization options
  • Support for multiple languages
  • Integration with popular NLP libraries

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use TextInsights in your research, please cite:

@software{textinsights2025,
  author = {ksg-dev},
  title = {TextInsights: A Python package for text analysis and visualization},
  year = {2025},
  url = {https://github.com/ksg-dev/textinsights}
}

Contact

ksg-dev - ksg.dev.data@gmail.com

Project Link: https://github.com/ksg-dev/textinsights

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

textinsights-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

textinsights-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file textinsights-0.1.0.tar.gz.

File metadata

  • Download URL: textinsights-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for textinsights-0.1.0.tar.gz
Algorithm Hash digest
SHA256 458b6549188198e3ad287d743cd726b993a4826e1a8a3d2daa720a229a3433e1
MD5 a120399273c66095018e0e1cd367df78
BLAKE2b-256 fc0fa863504e37a5f3ca076858d0cba3c56f517a8ddffee5b1703d57011f064b

See more details on using hashes here.

File details

Details for the file textinsights-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: textinsights-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for textinsights-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c459c630241dd749c6b81262ba5f23da533b49ba9e6c16feff8b0fcffc7b8ed
MD5 93816f213759069cd8201c1aee9f4840
BLAKE2b-256 cf674a5287ec057061a12b6301439830870987a07f8972f8c1e2cbaa2d6bedef

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