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 striking anomaly in our sentiment data: a 24-hour momentum spike of -0.450 in the software sector. This drop, marked by a lack of positive sentiment and a notable number of articles processed, suggests a significant shift in how software is being perceived. The absence of related articles further highlights this unusual occurrence, making it a prime candidate for deeper analysis.

In any sentiment analysis pipeline that doesn't accommodate multilingual origins or entity dominance, gaps can quickly form. For instance, your model may have missed this spike by several hours, particularly if it was focused solely on English-language sources. Given that the software market is a global arena, overlooking sentiments from non-English articles can lead to critical delays in recognizing shifts in public opinion. This is especially true when the dominant language or entity, like English in software discussions, overshadows others, leading to blind spots in your assessments.

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

To catch this anomaly in Python, we can leverage our API effectively. Here’s how you can implement it:

import requests

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


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

# Geographic origin filter (assuming we had data)
geo_filter_data = {
    "topic": topic,
    "region": "global"  # Adjust based on availability
}

![[DATA UNAVAILABLE: countries  verify /news_recent is return](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_geo_output_1773307170032.png)
*[DATA UNAVAILABLE: countries  verify /news_recent is returning country/region values for topic: software]*


# Check for geographic data
# Note: Data Unavailable: no geo filter data returned
# Make sure to verify /dataset/daily_dataset and /news_recent for topic: software

response_geo = requests.get(f"https://api.pulsebit.com/dataset/daily_dataset", params=geo_filter_data)
geo_data = response_geo.json()

# If geo data was available, filter results
if geo_data:
    print("Geo-filtered results:", geo_data)
else:
    print("No geographic data available. Proceeding without geo filter.")

# Meta-sentiment moment
cluster_reason = "Clustered by shared themes: service, (saas), market, expected, reach."
meta_sentiment_response = requests.post("https://api.pulsebit.com/sentiment", json={"text": cluster_reason})
meta_sentiment_score = meta_sentiment_response.json()
print("Meta-sentiment score:", meta_sentiment_score)
Enter fullscreen mode Exit fullscreen mode

In the code above, we first attempt to filter the sentiment data based on geographic origin. While we faced a limitation due to the unavailability of geo-filter data, it’s essential to highlight that when such data is accessible, you can gain significant insights by examining regional sentiment variations. Next, we run the cluster reason string through the sentiment scoring endpoint. This step is crucial; it allows us to evaluate the narrative framing of the sentiment around software, particularly in the context of the SaaS market.

Now, let's talk about three specific builds we can derive from this anomaly:

  1. Geo-Filtered Alerts: Set up alerts based on geographic data when a sentiment spike (like our -0.450 momentum) occurs. Use the endpoint for articles related to 'software' in specific regions to get localized insights.

  2. Meta-Sentiment Analysis Dashboard: Create a dashboard that showcases the meta-sentiment scores derived from cluster reasons for various topics like software, SaaS, and market expectations. This can help visualize how narratives evolve over time.

  3. Forming Themes Analysis: Build a script that automatically tracks forming themes related to software. You can use the endpoint to fetch articles with links like "https://news" and cross-reference them with sentiment scores to identify potential narrative shifts early.

By continuously monitoring these patterns, you can position yourself ahead of sentiment trends and ensure your decisions are rooted in comprehensive data.

For more details on how to get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy, paste, and run this in under 10 minutes.

Top comments (0)