DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 26.9h Behind: Catching Mobile Sentiment Leads with Pulsebit

Your pipeline is 26.9h behind: catching mobile sentiment leads with Pulsebit

We recently uncovered an anomaly: a 24-hour momentum spike of +0.172 related to the topic "mobile." This spike highlights a critical shift in sentiment that we need to pay attention to. The narrative surrounding this momentum is further amplified by a cluster story that reads, "Mobile woman killed, several injured in Baldwin County boating crash - Yellowham." It’s evident that something significant is happening, and we need to dive deeper into these data patterns to leverage this insight effectively.

The Problem

This anomaly reveals a structural gap in any pipeline that doesn't account for multilingual origin or entity dominance. If your model is based solely on mainstream English narratives, you could have missed this sentiment shift by 26.9 hours. The leading language for this spike is English, yet the sentiment is driven by a tragic event that likely resonates in various local languages and communities. If you’re not capturing these nuanced narratives, you’re at risk of lagging behind crucial sentiment trends that could inform your decisions.

English coverage led by 26.9 hours. Ca at T+26.9h. Confidenc
English coverage led by 26.9 hours. Ca at T+26.9h. Confidence scores: English 0.85, Spanish 0.85, Ro 0.85 Source: Pulsebit /sentiment_by_lang.

The Code

Here’s how we can catch this spike using our API. First, we’ll filter for English language articles to ensure we’re capturing the right sentiment. Here’s the code to do that:

import requests

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

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


response = requests.get("https://api.pulsebit.com/v1/sentiment", params=params)
data = response.json()

momentum = data['momentum_24h']
score = data['sentiment_score']
confidence = data['confidence']

print(f"Momentum: {momentum}, Score: {score}, Confidence: {confidence}")
Enter fullscreen mode Exit fullscreen mode

Next, we’ll process the cluster reason string to score the sentiment narrative itself. This allows us to understand the context behind the spike better:

# Meta-sentiment moment
cluster_reason = "Clustered by shared themes: woman, killed, baldwin, several, injured."

meta_response = requests.post("https://api.pulsebit.com/v1/sentiment", json={"text": cluster_reason})
meta_data = meta_response.json()

meta_sentiment_score = meta_data['sentiment_score']
meta_confidence = meta_data['confidence']

print(f"Meta Sentiment Score: {meta_sentiment_score}, Meta Confidence: {meta_confidence}")
Enter fullscreen mode Exit fullscreen mode

Three Builds Tonight

With this newfound insight, here are three specific things you can build:

  1. Geo-Filtered Alerts: Set up an alert system that triggers whenever there’s a momentum spike of +0.172 or higher in English-language articles about "mobile." Use the geographic origin filter to ensure you capture local sentiment effectively. Threshold: momentum >= +0.172.

Geographic detection output for mobile. India leads with 4 a
Geographic detection output for mobile. India leads with 4 articles and sentiment +0.35. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Analysis Dashboard: Create a dashboard that visualizes the sentiment scores of the narratives surrounding clustered stories. Use the meta-sentiment loop for deeper insights into the context of each cluster. This can be particularly useful in understanding how stories evolve over time.

  2. Story Clustering Engine: Build an engine that identifies other emerging stories in your dataset that share themes with the current momentum spike. For example, look for keywords like "mobile," "county," and "injured" to find related narratives. This can help you stay ahead of the trends.

Get Started

Ready to dive in? Visit pulsebit.lojenterprise.com/docs. You can copy-paste the code snippets provided and run them in under 10 minutes. Let’s turn data insights into actionable intelligence!

Top comments (0)