DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 21.9h Behind: Catching Robotics Sentiment Leads with Pulsebit

Your Pipeline Is 21.9h Behind: Catching Robotics Sentiment Leads with Pulsebit

We recently uncovered a striking anomaly: a 24-hour momentum spike of +0.557 in the robotics sector. This surge is particularly intriguing as it comes amidst growing discussions about China's ambitions in humanoid robotics. With two articles clustered around this theme, it seems the narrative is gaining traction, and the implications are worth exploring.

The Problem

This momentum spike reveals a critical gap in any pipeline that doesn't account for multilingual origins or entity dominance. If your model doesn’t handle these effectively, you might have missed this significant shift by 21.9 hours — that’s nearly a full day! The leading language is English, but the dominant narrative is emerging from a global context. If you’re not tuned in to these dynamics, you risk losing valuable insights that could inform your strategies.

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

The Code

To catch momentum spikes effectively, let’s dive into some Python code that leverages our API. The following code snippet filters for English-language articles about robotics and scores the sentiment of the clustered narrative.

First, we’ll query articles related to robotics:

import requests

# Parameters for the API call
params = {
    "topic": "robotics",
    "lang": "en"
}

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


# API endpoint for fetching articles
response = requests.get('https://api.pulsebit.com/v1/articles', params=params)
articles = response.json()
print(articles)  # Output: Articles related to robotics
Enter fullscreen mode Exit fullscreen mode

Next, we’ll run the cluster reason string through the sentiment analysis endpoint:

# Meta-sentiment moment
cluster_reason = "Clustered by shared themes: gives, young, fan, exclusive, look."
sentiment_response = requests.post('https://api.pulsebit.com/v1/sentiment', json={"text": cluster_reason})
sentiment_score = sentiment_response.json()
print(sentiment_score)  # Output: Sentiment analysis result
Enter fullscreen mode Exit fullscreen mode

By using this approach, you can not only capture the momentum but also understand the underlying narratives that are shaping sentiment.

Three Builds Tonight

Here are three specific builds you can create using this momentum spike:

  1. Geo-Filtered Sentiment Dashboard: Utilize the geographic origin filter to create a dashboard that visualizes sentiment around robotics across different countries. Set a threshold to alert you when sentiment spikes above +0.5 in English articles.

Geographic detection output for robotics. Hong Kong leads wi
Geographic detection output for robotics. Hong Kong leads with 2 articles and sentiment +0.77. Source: Pulsebit /news_recent geographic fields.

   # Threshold check
   if sentiment_score['score'] > 0.5:
       alert_user("Significant sentiment spike detected in robotics!")
Enter fullscreen mode Exit fullscreen mode
  1. Meta-Sentiment Trend Analysis: Build a function that analyzes the narrative themes over time. Use our sentiment endpoint to score narratives associated with the keywords "robotics", "google", and "company". Look for shifts in sentiment that could indicate emerging trends.
   # Check for shifts in sentiment over time
   narrative_themes = ["robotics", "google", "company"]
   for theme in narrative_themes:
       # Assuming you have historical sentiment data
       historical_sentiment = get_historical_sentiment(theme)
       if historical_sentiment['score'] < 0:
           print(f"Alert: Negative sentiment trend detected for {theme}.")
Enter fullscreen mode Exit fullscreen mode
  1. Clustered Sentiment Alerts: Create an alert system that notifies you when articles containing specific words like "young" or "fan" cluster around a topic. This can reveal shifts in consumer interest or emerging demographics.
   # Alert for clustered article themes
   if "young" in cluster_reason or "fan" in cluster_reason:
       notify_users("New consumer interest detected in robotics.")
Enter fullscreen mode Exit fullscreen mode

Get Started

If you want to dig deeper into this, head over to pulsebit.lojenterprise.com/docs. You can easily copy-paste the code and run it in under 10 minutes. This is how we harness the power of sentiment to stay ahead of the curve.

Top comments (0)