DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 28.8h Behind: Catching Business Sentiment Leads with Pulsebit

Your Pipeline Is 28.8h Behind: Catching Business Sentiment Leads with Pulsebit

Recently, we discovered a significant anomaly: a sentiment score of -0.127, coupled with a momentum of +0.030, indicating a critical shift in business sentiment. Specifically, the leading language was English, and our analysis revealed a 28.8-hour lag, with no delay in Netherlands sentiment. The particular cluster we observed revolved around a police investigation into an arson attack in north-west London—two articles triggered this spike. This is a clear signal that your data pipeline might be missing key insights if it isn't equipped to handle multilingual origins or dominant entities effectively.

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

For any pipeline that lacks the ability to consider these factors, you risk missing critical shifts in sentiment. Your model missed this by 28.8 hours, while the English language narratives surrounding police, arson, and business continued to evolve. Without a robust multilingual framework, you could easily overlook nuanced developments that are shaping the business landscape—like this emerging narrative that could impact market sentiment.

Here’s how we can catch this anomaly in our data pipeline using Python. First, let’s filter our query by language to focus on English content:

import requests

# Set parameters for the API call
params = {
    "topic": "business",
    "lang": "en"
}

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


# Make the API call to get sentiment data
response = requests.get("https://api.pulsebit.com/sentiment", params=params)
data = response.json()

# Output the relevant sentiment details
print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we need to run the cluster reason string back through our sentiment API to score the narrative itself. This is crucial for assessing how the framing of the narrative influences overall sentiment:

# Defining the cluster reason string
cluster_reason = "Clustered by shared themes: businessman, assaulting, police, medical, booked."

# Make the API call to get sentiment on the cluster reason
response_meta = requests.post("https://api.pulsebit.com/sentiment", json={"text": cluster_reason})
meta_sentiment_data = response_meta.json()

# Output the sentiment score for the narrative
print(meta_sentiment_data)
Enter fullscreen mode Exit fullscreen mode

Now that we have this functionality in place, here are three specific builds you can implement using this pattern:

  1. Signal Alert System: Create a real-time alert system that triggers when sentiment around "business" falls below a threshold of -0.1, indicating a negative shift. Use the geo filter from the above code to ensure you're only monitoring regions of interest.

  2. Meta-Sentiment Dashboard: Build a dashboard that visualizes the sentiment score of cluster reasons like "Clustered by shared themes: police, arson, attack, London." This will help you see how narrative framing affects public perception, using the meta-sentiment loop we demonstrated.

  3. Gap Analysis Report: Implement a report that compares the sentiment data from English sources to other languages, specifically looking at themes like "business" and "police." This can help identify where you might be lagging or missing critical information, especially when the mainstream narrative diverges.

To get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the code provided above and run it in under 10 minutes to begin catching those important business sentiment leads!

Geographic detection output for business. India leads with 5
Geographic detection output for business. India leads with 5 articles and sentiment +0.49. Source: Pulsebit /news_recent geographic fields.

Top comments (0)