DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 28.9h Behind: Catching Energy Sentiment Leads with Pulsebit

Your Pipeline Is 28.9h Behind: Catching Energy Sentiment Leads with Pulsebit

We recently discovered a notable 24h momentum spike of -0.763 in the energy sector, leading us to explore the implications of this anomaly. The data shows that the leading language is French, with a remarkable lag of 28.9 hours compared to its Italian counterpart. This revelation highlights a gap in our pipelines when it comes to handling multilingual origins and entity dominance.

French coverage led by 28.9 hours. Italian at T+28.9h. Confi
French coverage led by 28.9 hours. Italian at T+28.9h. Confidence scores: French 0.75, English 0.75, Spanish 0.75 Source: Pulsebit /sentiment_by_lang.

The Problem

If your model doesn't account for multilingual sentiment or the dominance of entities, you may have missed significant opportunities. In this case, your model overlooked the sentiment coming from France, which saw a significant sentiment score of +0.111 for China, the dominant entity with a 6% share of voice. By ignoring this, you missed the insight by nearly 29 hours. This lag can mean the difference between capitalizing on emerging trends and being blindsided by them.

The Code

Here’s how we can catch this sentiment spike using Python and our API. We’ll start by querying articles in French that mention the topic of energy, considering the momentum and sentiment scores.

import requests

# Define the parameters for our initial query
params = {
    'topic': 'energy',
    'lang': 'fr',  # Filtering by French language
    'score': +0.000,
    'confidence': 0.75,
    'momentum': -0.763
}

# API call to fetch the relevant articles
response = requests.get('https://api.pulsebit.io/articles', params=params)
print(response.json())
Enter fullscreen mode Exit fullscreen mode

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

Now, let’s run the narrative framing through our sentiment scoring endpoint. We’ll input the cluster reason string to analyze how the articles frame the narrative.

# Define the cluster reason string
cluster_reason = "Clustered by shared themes: data, has, war, veteran's, home."

# API call to score the narrative framing
sentiment_response = requests.post('https://api.pulsebit.io/sentiment', json={"text": cluster_reason})
print(sentiment_response.json())
Enter fullscreen mode Exit fullscreen mode

This two-step process allows us to not only filter articles based on language and topic but also analyze the sentiment surrounding the clustered themes, giving us a clearer picture of the emerging narratives.

Three Builds Tonight

  1. Energy Momentum Alert: Set a threshold for momentum spikes. If momentum drops below -0.5, trigger an alert. Use the geo filter to ensure you’re only capturing relevant data from specific regions, like China or France.

  2. Meta-Sentiment Analyzer: Create a function that utilizes the meta-sentiment loop we demonstrated. By feeding in cluster themes, you can dynamically adjust your content strategy based on how narratives are framed. This could be particularly useful for identifying trends in energy discussions.

  3. Forming Gap Tracker: Implement a tracker that continually monitors forming themes in real-time. For example, keep an eye on ‘forming: energy(+0.00), google(+0.00), news(+0.00)’ to spot anomalies compared to the mainstream narratives, such as ‘data, has, war’. This can give you an early indication of shifts in sentiment.

Get Started

Ready to dive in? Head over to pulsebit.lojenterprise.com/docs. We believe you can copy-paste and run this in under 10 minutes. Let’s get to work on making your pipeline more responsive to emerging trends!

Geographic detection output for energy. India leads with 6 a
Geographic detection output for energy. India leads with 6 articles and sentiment -0.42. Source: Pulsebit /news_recent geographic fields.

Top comments (0)