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 recently observed a significant anomaly: a 24-hour momentum spike of -0.450 in the software sector. This drop is particularly striking considering the current landscape of the Software as a Service (SaaS) market, which is projected to reach US$908.2 billion. That's a huge story, yet our data suggests an unprecedented shift in sentiment that warrants investigation.

When your pipeline doesn't accommodate multilingual origins or entity dominance, you're missing critical insights. In this case, you might have overlooked this anomaly for several hours. The leading language here is English, and as you parse through sentiment data, not being able to filter out non-relevant data points can distort your findings. This is where our API can help you bridge those gaps.

en coverage led by 9.6 hours. id at T+9.6h. Confidence score
en coverage led by 9.6 hours. id at T+9.6h. Confidence scores: en 0.87, fr 0.85, es 0.85 Source: Pulsebit /sentiment_by_lang.

import requests

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


# Define the parameters for the anomaly detection
topic = 'software'
score = +0.000
confidence = 0.00
momentum = -0.450

# Geographic origin filter - note: this won't work without geo data
# Example query: filter by English-speaking regions
geo_filter = {'language': 'en', 'country': 'US'}

response = requests.get(f"https://api.pulsebit.lojenterprise.com/dataset/daily_dataset?topic={topic}&geo_filter={geo_filter}")
data = response.json()

# Check for articles processed and momentum
if data['articles_processed'] > 0 and momentum < -0.2:
    print("Anomaly detected in the sentiment for software."""
Enter fullscreen mode Exit fullscreen mode

Currently, geographic filtering is not available due to limitations in our dataset, but when the data is accessible, it can significantly refine your analysis.

![DATA UNAVAILABLE: countries — verify /news_recent is return
[DATA UNAVAILABLE: countries — verify /news_recent is returning country/region values for topic: software]

Next, let’s assess the meta-sentiment moment. We'll run the cluster reason string back through the /sentiment endpoint to quantify how the narrative is framed around this anomaly.

# Analyze the meta-sentiment
cluster_reason = "Clustered by shared themes: service, (saas), market, expected, reach."
meta_sentiment_response = requests.post("https://api.pulsebit.lojenterprise.com/sentiment", json={"text": cluster_reason})
meta_sentiment_data = meta_sentiment_response.json()

print(f"Meta sentiment score: {meta_sentiment_data['score']}, Confidence: {meta_sentiment_data['confidence']}")
Enter fullscreen mode Exit fullscreen mode

This allows us to objectively evaluate the narrative framing, crucial for understanding the context behind the numbers.

Now, let's explore three specific actions we can take based on this momentum spike and the forming themes around software:

  1. Trend Analysis: Set up a threshold alert for any software sentiment momentum below -0.2. This will help capture similar anomalies rapidly.

  2. Local Insights: Once geographic data is available, implement a filter to focus on English-speaking regions, allowing you to understand how different markets react to software trends.

  3. Narrative Mining: Use the meta-sentiment analysis as a feedback loop in your models. For example, if the sentiment around “service” and “SaaS” trends negatively, it may indicate a broader market concern that could influence your trading strategies.

As we continue to analyze news around software, especially with emerging stories like the SaaS market's growth, we encourage you to leverage these techniques. You can get started by diving into our documentation at pulsebit.lojenterprise.com/docs.

With just a few lines of code, you can copy-paste and run this analysis in under 10 minutes, potentially uncovering anomalous trends that could shape your next decision. Happy coding!

Top comments (0)