DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 23.9h Behind: Catching Defence Sentiment Leads with Pulsebit

Your model might have missed a critical 24h momentum spike of +0.516 related to the topic of "defence." This anomaly surfaced from the English press, which led with a 23.9-hour advance on the sentiment narrative surrounding France's ban on Israeli weapons at a defence show. Not only does this data highlight a significant surge in sentiment, but it also indicates a notable gap in how your pipeline handles multilingual origins and entity dominance. The reliance on a single language could lead to missed opportunities, especially when significant shifts occur in other languages or regions.

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

If your sentiment analysis pipeline isn't equipped to handle multilingual sources or prioritize dominant entities, it may miss important insights like this one. Your model missed this spike by 23.9 hours, meaning that you could have reacted to a crucial news story earlier. The leading language here was English, which might overshadow other relevant narratives coming from different linguistic sources. This delay could cost you time-sensitive opportunities, especially in a fast-moving landscape like defence.

Here's how to catch this anomaly using our API. We can set up a query to filter for the "defence" topic and look for sentiment in English:

import requests

# Define the parameters for the API call
params = {
    "topic": "defence",
    "lang": "en",
    "score": 0.700,
    "confidence": 0.90,
    "momentum": 0.516
}

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


# Make the API call to fetch articles
response = requests.get('https://api.pulsebit.io/articles', params=params)
articles = response.json()
Enter fullscreen mode Exit fullscreen mode

Once we have the articles, we can analyze the narrative framing. Let's run the cluster reason string back through our sentiment endpoint to evaluate its meta-sentiment. For our example, we'll input the themes identified:

# Define the cluster reason input
cluster_reason = "Clustered by shared themes: sexual, violence, landmark, military, inquiry."

# Make the API call to score the narrative framing
sentiment_response = requests.post('https://api.pulsebit.io/sentiment', json={"text": cluster_reason})
sentiment_score = sentiment_response.json()
Enter fullscreen mode Exit fullscreen mode

This double-checks the sentiment narrative itself, helping you understand how the framing of the story influences the overall sentiment score.

Now, let’s look at three specific builds you can create with this pattern:

  1. Geo Filter for Defence Insights: Use the geographic origin filter to identify sentiment spikes in specific regions. Set up a threshold where any momentum score above +0.400 triggers an alert. This ensures you’re aware of significant sentiment shifts in regions discussing "defence" topics.

Geographic detection output for defence. India leads with 7
Geographic detection output for defence. India leads with 7 articles and sentiment +0.31. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Loop for Emerging Narratives: Implement the meta-sentiment scoring to detect emerging stories. If you find a cluster reason scoring above +0.600, consider this a signal to prioritize this news in your analyses. This could reveal hidden narratives that impact your understanding of current events.

  2. Forming Themes Analysis: Create a dedicated endpoint to track forming themes like "defence," "google," and "minister." Set a signal threshold of +0.300 when compared to mainstream themes like "sexual," "violence," and "landmark." This will help you focus on proactive strategies rather than reactive ones.

To get started with these insights, head over to our documentation at pulsebit.lojenterprise.com/docs. You can easily copy-paste the above code and run it in under 10 minutes to capture this vital sentiment data.

Top comments (0)