DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 27.4h Behind: Catching Human Rights Sentiment Leads with Pulsebit

Your Pipeline Is 27.4h Behind: Catching Human Rights Sentiment Leads with Pulsebit

We recently discovered a fascinating anomaly: a 24-hour momentum spike of +1.054 for the topic of "human rights." This spike isn't just a number; it reflects a significant shift in sentiment that demands our attention. Leading the charge is a French press article, with a notable 27.4-hour lead time. This is a clear indicator that our current pipelines may not be fully capturing the nuances of multilingual origins and entity dominance. If your model isn’t prepared for this, it missed capturing this vital sentiment shift by over a day.

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

The problem here is clear: without a pipeline that effectively processes multilingual data or recognizes entity dominance, you're at risk of missing critical updates. In this case, the leading language was French, and the dominant narrative was centered around Adivasi-Dalit groups advocating for rights. If your system only processes English content or doesn't account for language variations, you might be 27.4 hours late on spotting emerging themes.

Let’s dive into the code that can help capture this sentiment spike effectively. First, we’ll filter for articles in French to ensure we’re capturing the right data. Here’s how we can do that using our API:

import requests

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


# Define the API endpoint and parameters
url = "https://api.pulsebit.com/v1/articles"
params = {
    "topic": "human rights",
    "lang": "fr",
    "momentum": 1.054
}

# Make the GET request
response = requests.get(url, params=params)
data = response.json()
print(data)
Enter fullscreen mode Exit fullscreen mode

Now that we have our articles filtered by language, we need to analyze the thematic framing of the cluster identified in our findings. To do this, we can send the cluster reason string back through our sentiment scoring endpoint. Here’s how that looks:

# Define the meta-sentiment endpoint
sentiment_url = "https://api.pulsebit.com/v1/sentiment"

# Input the cluster reason
cluster_reason = "Clustered by shared themes: rights, muthanga, adivasi-dalit, groups, hold."
sentiment_params = {
    "text": cluster_reason
}

# Make the POST request
sentiment_response = requests.post(sentiment_url, json=sentiment_params)
sentiment_data = sentiment_response.json()
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

By running the above code, you can get insights into how the narrative is being framed and how it relates to the overall sentiment on human rights. This two-step approach — filtering by language and analyzing sentiment — gives you a robust framework for catching emerging trends.

Now that we’ve established the groundwork, here are three specific builds you can implement with this pattern:

  1. Geo-Filtered Insights: Use the geographic origin filter to monitor French-speaking regions for spikes in human rights sentiment. Set a threshold to trigger alerts if momentum surpasses +1.0. This allows you to react quickly to rising narratives.

Geographic detection output for human rights. India leads wi
Geographic detection output for human rights. India leads with 4 articles and sentiment +0.17. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Analysis: Create a script that automatically analyzes the sentiment of clustered themes every 12 hours. If any theme scores above 0.7, log it for further analysis. This will help in identifying narratives that may require immediate attention.

  2. Comparative Theme Analysis: Build a comparison tool that evaluates forming themes like "rights," "human," and "google" against established mainstream narratives. Set thresholds to highlight when a new theme shows a significant divergence, particularly if it’s previously unreported.

Ready to dive in? Check out our documentation at pulsebit.lojenterprise.com/docs. You can copy, paste, and run this code in under 10 minutes to start catching vital sentiment shifts before they hit the mainstream.

Top comments (0)