DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 26.2h Behind: Catching Governance Sentiment Leads with Pulsebit

In the last 24 hours, we observed a notable anomaly with a momentum spike of -0.325. This unusual decrease in momentum suggests a significant shift in sentiment worth investigating, especially in the context of governance. Our analysis reveals that the leading language contributing to this spike is French, with a 26.2-hour lag in reporting. This indicates that if your current pipeline does not account for multilingual origins and entity dominance, you might be missing crucial developments — developments that are already being spoken about in French media but haven’t yet reached your models.

French coverage led by 26.2 hours. Da at T+26.2h. Confidence
French coverage led by 26.2 hours. Da at T+26.2h. Confidence scores: French 0.90, English 0.90, Spanish 0.90 Source: Pulsebit /sentiment_by_lang.

The gap is glaring: your model missed this by over a full day. With a dominant entity like Africa representing an 8% share of voice and a positive sentiment score of +0.575, the implications are clear. If you're relying solely on English-language data or neglecting the relevance of local narratives, you're likely missing out on critical insights that could inform your strategy or decision-making.

Here's how we can catch this anomaly using Python. We will leverage our API to filter for content based on geographic origin and then analyze the sentiment of the cluster narrative itself.

Geographic detection output for governance. India leads with
Geographic detection output for governance. India leads with 2 articles and sentiment +0.77. Source: Pulsebit /news_recent geographic fields.

import requests

# Parameters for the API call
url = "https://api.pulsebit.com/v1/articles"
params = {
    "topic": "governance",
    "lang": "fr",  # Filtering for French language
    "momentum": -0.325,
    "score": +0.192,
    "confidence": 0.90
}

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


# Making the API call to get articles
response = requests.get(url, params=params)
articles = response.json()

# Analyzing the cluster narrative
cluster_reason = "Clustered by shared themes: prakasam, district, collector, special, officer."
sentiment_analysis_url = "https://api.pulsebit.com/v1/sentiment"
sentiment_response = requests.post(sentiment_analysis_url, json={"text": cluster_reason})
sentiment_score = sentiment_response.json()

print(f"Sentiment Analysis: {sentiment_score}")
Enter fullscreen mode Exit fullscreen mode

In this code, we first query the articles with a specific focus on the topic "governance" and filter for French language content. The momentum and score parameters help us hone in on the relevant articles. After retrieving the articles, we run the cluster narrative string through the sentiment API to gauge how the framing of this narrative might influence our understanding of the overall sentiment.

Now that we've caught this anomaly, here are three specific builds we can implement:

  1. Geolocation Filter: Create a signal that monitors the sentiment around governance in French-speaking African countries. Use the geo filter to assess sentiment fluctuations, especially when momentum is below a certain threshold (e.g., -0.300).

  2. Meta-Sentiment Loop: Develop a continuous feedback mechanism where the sentiment of the cluster narrative is evaluated alongside the momentum of key topics like governance, sustainability, and technology. This allows for adaptive responses to emerging themes.

  3. Forming Themes Alert: Set up alerts for forming themes such as governance, Google, and sustainability when their sentiment scores are near zero. Use the mainstream context of "prakasam, district, collector" to identify emerging risks or opportunities.

To get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can easily copy-paste the code provided above and have it running in under 10 minutes. Get ready to catch those crucial insights before they slip through the cracks!

Top comments (0)