DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 15.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

Your Pipeline Is 15.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

We recently uncovered a striking anomaly: a 24-hour momentum spike of +0.800, specifically around the topic of sustainability. This spike reflects a significant shift in sentiment, led by English-language press coverage, which is notable for being 15.9 hours ahead of other languages. If you’re not tracking multilingual sentiment, your models may be missing crucial insights, lagging behind the conversations that matter.

English coverage led by 15.9 hours. Nl at T+15.9h. Confidenc
English coverage led by 15.9 hours. Nl at T+15.9h. Confidence scores: English 0.85, Spanish 0.85, French 0.85 Source: Pulsebit /sentiment_by_lang.

When your pipeline doesn’t account for the nuances of multilingual origins or dominant entities, you’re risking a disconnect. For instance, while the English press is buzzing about sustainability, your model may be stuck on outdated data from other languages or perspectives, missing this pivotal moment by nearly 16 hours. This is critical—especially when it comes to a theme as impactful as sustainability, which could shape market dynamics and consumer behavior.

Let’s dive into the code that can help us catch these emerging trends. We’ll start by querying our data through our API with a geographic origin filter, specifically focusing on English language sources.

import requests

# API endpoint for fetching sentiment data
api_url = "https://api.pulsebit.com/v1/sentiment"

# Query parameters
params = {
    "topic": "sustainability",
    "lang": "en",
    "momentum": "+0.800",
    "score": +0.775,
    "confidence": 0.85
}

# Making the API call
response = requests.get(api_url, params=params)
data = response.json()
print(data)
Enter fullscreen mode Exit fullscreen mode

Left: Python GET /news_semantic call for 'sustainability'. R
Left: Python GET /news_semantic call for 'sustainability'. Right: returned JSON response structure (clusters: 3). Source: Pulsebit /news_semantic.

Next, we run the cluster reason string through our sentiment analysis endpoint to score the narrative surrounding this spike. This allows us to understand the framing of the conversation itself.

# Meta-sentiment analysis on the cluster reason
meta_sentiment_url = "https://api.pulsebit.com/v1/sentiment"
narrative = "Clustered by shared themes: sustainability, recommits, data, centre, eudca."

# Making the API call for meta sentiment
meta_response = requests.post(meta_sentiment_url, json={"text": narrative})
meta_data = meta_response.json()
print(meta_data)
Enter fullscreen mode Exit fullscreen mode

With this code, we're leveraging both geographic filters and meta-sentiment analysis, allowing us to catch the nuances in the evolving narrative around sustainability.

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

Now, let’s consider three specific builds we can implement with the insights from this data anomaly:

  1. Geo-Filtered Real-Time Alerts: Create a threshold alert that triggers when the momentum score exceeds +0.800 for the topic of sustainability in English. This ensures you are immediately informed of significant sentiment shifts.

  2. Narrative Framing Reports: Build a report that leverages the meta-sentiment analysis to provide insights into how narratives around sustainability are framed, particularly focusing on how often terms like "recommits" and "data" appear in conjunction with the topic.

  3. Cross-Language Sentiment Comparison: Set up an endpoint that compares sentiment scores for sustainability across multiple languages, identifying gaps. For example, it should track the forming gap between English sentiment and other languages like Dutch, focusing on themes like sustainability(+0.00), Google(+0.00), and Africa(+0.00).

These builds not only help in real-time sentiment tracking but also provide deeper insights into how sustainability themes are evolving across different contexts and languages.

Get started with our documentation at pulsebit.lojenterprise.com/docs. In under 10 minutes, you can copy, paste, and run the necessary code to catch these critical sentiment leads. Don’t let your models fall behind—stay ahead of the curve with precise, actionable insights.

Top comments (0)