Skip to main content

Sentix

A lightweight and explainable rule-based sentiment analysis library for Python.

Sentix provides sentiment classification with support for:

  • Positive sentiment
  • Negative sentiment
  • Neutral sentiment
  • Mixed sentiment
  • Negation handling
  • Intensity modifiers
  • Diminishers
  • Contrast detection
  • Aspect-based sentiment
  • Emotion detection
  • Confidence scoring
  • Evidence-based explanations

Installation

pip install sentix

Quick Start

from sentix import SentimentAnalyzer

analyzer = SentimentAnalyzer()

result = analyzer.predict(
    "I love the camera, but I hate the battery."
)

print(result.label)
print(result.score)
print(result.confidence)

Example output:

mixed
0.0
0.49

Full Result

from sentix import SentimentAnalyzer

analyzer = SentimentAnalyzer()

result = analyzer.predict(
    "The camera is amazing, but the battery is terrible."
)

print(result.to_dict())

Example structure:

{
    "label": "mixed",
    "score": 0.0,
    "positive": 0.5,
    "negative": 0.5,
    "neutral": 0.0,
    "confidence": 0.49,
    "emotions": {},
    "aspects": {},
    "evidence": []
}

Supported Sentiment Labels

Sentix can return four sentiment labels:

Label Meaning
positive Overall positive sentiment
negative Overall negative sentiment
neutral No significant sentiment detected
mixed Both positive and negative sentiment detected

Negation

Sentix handles common negation patterns.

analyzer.predict("I don't like this.")

Expected sentiment:

negative

Example:

analyzer.predict("I don't think this is good.")

Expected sentiment:

negative

Intensity

Sentix supports intensity modifiers.

analyzer.predict(
    "This is extremely amazing."
)

The word extremely increases the strength of the sentiment.

Diminishers

Sentix also supports diminishing modifiers.

analyzer.predict(
    "The battery is slightly bad."
)

The negative sentiment is weaker than:

"The battery is terrible."

Contrast Handling

Sentix analyzes contrast expressions such as but.

analyzer.predict(
    "I love this, but the battery is terrible."
)

Contrast analysis considers sentiment before and after the contrast marker.

Mixed Sentiment

Sentix can detect conflicting sentiment.

analyzer.predict(
    "I love the screen, but I hate the battery."
)

Possible output:

mixed

Aspect-Based Sentiment

Sentix can identify sentiment associated with specific aspects.

result = analyzer.predict(
    "The camera is amazing but the battery is terrible."
)

print(result.aspects)

Example:

{
    "camera": {
        "sentiment": "positive",
        "score": 2.0
    },
    "battery": {
        "sentiment": "negative",
        "score": -2.0
    }
}

Emotion Detection

Sentix can detect emotion-related signals.

result = analyzer.predict(
    "I am extremely happy and excited."
)

print(result.emotions)

Evidence

Sentix provides explainable sentiment evidence.

result = analyzer.predict(
    "This product is extremely amazing!"
)

for item in result.evidence:
    print(item)

Evidence may include:

  • sentiment word
  • base score
  • intensity modifier
  • negation modifier
  • capitalization modifier
  • final score

Benchmark

Current benchmark results on the Sentix benchmark dataset:

Library Accuracy Macro F1
Sentix 97% 0.9632
VADER 83% 0.6793
TextBlob 69% 0.5264

Category Performance

Category Sentix
Basic 100%
Negation 100%
Intensity 100%
Diminisher 100%
Contrast 80%
Mixed 90%
Aspect 100%
Morphology 100%
Emphasis 100%
Neutral 100%

Testing

Run the complete test suite:

python -m pytest

Current status:

173 passed

Benchmark

Run:

python benchmarks/benchmark_sentiment.py

Performance

On the current benchmark dataset of 100 samples:

Sentix: approximately 0.036 seconds

This is approximately:

0.36 milliseconds per sample

Performance will vary depending on hardware and Python version.

Design Philosophy

Sentix focuses on:

  • Lightweight implementation
  • Explainability
  • Rule-based reasoning
  • No external machine learning model requirement
  • Fast inference
  • Transparent sentiment evidence

License

MIT License

Author

Sentix Contributors

Download files

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

Source Distribution

sentix-1.0.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

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

sentix-1.0.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sentix-1.0.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for sentix-1.0.0.tar.gz
Algorithm Hash digest
SHA256 15cfacdbe7f313eaa35b60cc23a79a91db22e320e7eecbaf739aed8af1241da7
MD5 0c4432c16336d5e5b017ba23156bc75d
BLAKE2b-256 df3aaaebce18d695bb752d343e5f881819db051af0346b558dd2c5827ce32fa8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sentix-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for sentix-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68f083c0b6628ceeb06c16a699b2310fd56669c9ebfde7e6c79824816ff4e7f5
MD5 04eca1f4f7396aa8131e1d857d9a0bc1
BLAKE2b-256 5fc3a259c19b3c34194b2c1135e526f47c98b3de4b759133609d8fc604d78c31

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page