DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

How to Detect Software Sentiment Anomalies with the Pulsebit API (Python)

How to Detect Software Sentiment Anomalies with the Pulsebit API (Python)

We just uncovered a notable anomaly: a 24-hour momentum spike of -0.450 in the software sector. This drop raises questions about what's happening in the SaaS market, especially considering the cluster story titled "Software as a Service (SaaS) Market Expected to Reach US$908.2" with zero articles discussing it. This stark disconnect hints at potential sentiment shifts that our models need to capture more effectively.

The Problem

This anomaly reveals a significant gap in any sentiment analysis pipeline that doesn't account for multilingual origins or entity dominance. Imagine your model missed this critical sentiment drop by a full 24 hours, leaving you blind to the emerging narrative around the software industry. With English being the leading language for tech sentiment, overlooking non-English sources could mean missing crucial insights, especially when the data is clustered around a key topic like SaaS.

en coverage led by 18.7 hours. id at T+18.7h. Confidence sco
en coverage led by 18.7 hours. id at T+18.7h. Confidence scores: en 0.86, es 0.85, fr 0.85 Source: Pulsebit /sentiment_by_lang.

The Code

To catch this anomaly, we can leverage our API effectively. Here's the Python code you can use to analyze this sentiment shift:

import requests

![Left: Python GET /news_semantic call for 'software'. Right: ](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_code_output_split_1773275106916.png)
*Left: Python GET /news_semantic call for 'software'. Right: returned JSON response structure (clusters: 3). Source: Pulsebit /news_semantic.*


# Input values
topic = 'software'
score = +0.000
confidence = 0.00
momentum = -0.450

# Geographic origin filter — note that this will only work if geo data is available
geo_filter = 'en-US'  # Example for English/United States
url_geo = f'https://api.pulsebit.lojenterprise.com/sentiment?topic={topic}&region={geo_filter}'

# Fetch geo-filtered data (assuming geo data is available)
geo_response = requests.get(url_geo)
geo_data = geo_response.json()

# Meta-sentiment moment: scoring the cluster reason string
cluster_reason = "Clustered by shared themes: service, (saas), market, expected, reach."
url_meta_sentiment = 'https://api.pulsebit.lojenterprise.com/sentiment'
meta_response = requests.post(url_meta_sentiment, json={'text': cluster_reason})
meta_sentiment_score = meta_response.json()['score']

print("Geo Filter Data:", geo_data)
print("Meta Sentiment Score:", meta_sentiment_score)
Enter fullscreen mode Exit fullscreen mode

In this code, we first query the sentiment for the topic "software" with a geographic filter. It’s crucial to mention that geo filtering only works when the necessary language or country data is available. Following that, we run the cluster reason string through our sentiment analysis endpoint to score the narrative framing itself. This unique step allows us to understand how the themes are being perceived sentimentally.

Geographic detection output for software. au leads with 1 ar
Geographic detection output for software. au leads with 1 articles and sentiment +0.00. Source: Pulsebit /news_recent geographic fields.

Three Builds Tonight

With this anomaly in mind, here are three specific builds we can implement:

  1. Geo-Filtered Alerts: Set up an alert system that triggers when sentiment drops below a certain threshold (e.g., -0.400) for the software topic in specific regions. This would help you catch regional anomalies early.

  2. Meta-Sentiment Dashboard: Create a visual dashboard that tracks the sentiment scores of narrative themes automatically. Use the meta-sentiment loop from our previous code to enrich insights into how these narratives change over time.

  3. Forming Theme Analyzer: Build a tool that scans for forming themes like "service" and "market" within the software industry. Use our endpoint to compare recent sentiment scores with historical benchmarks, ensuring you capture context around spikes and dips.

Get Started

Dive right in at pulsebit.lojenterprise.com/docs. You can copy, paste, and run this code in under 10 minutes to start detecting anomalies in software sentiment today!

Top comments (0)