DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 27.7h Behind: Catching World Sentiment Leads with Pulsebit

Your Pipeline Is 27.7h Behind: Catching World Sentiment Leads with Pulsebit

We just uncovered an anomaly with a 24h momentum spike of +0.262 in sentiment around the topic of "world." This spike is particularly intriguing because it is driven by two articles about Charlie Verco breaking a world paddleboarding record amidst a cluster of narratives involving sharks and rescues. The momentum climb has been led by English press articles, which are currently 27.7 hours ahead of other language sources. If you're not accounting for multilingual origins in your pipeline, you're missing out on critical, timely updates like these.

English coverage led by 27.7 hours. Et at T+27.7h. Confidenc
English coverage led by 27.7 hours. Et at T+27.7h. Confidence scores: English 0.85, Spanish 0.85, Id 0.85 Source: Pulsebit /sentiment_by_lang.

When your model isn't equipped to handle multilingual sources or entity dominance, it risks missing significant spikes like this one. In this case, you missed the story by 27.7 hours, which highlights a structural gap in your pipeline. The leading language is English, yet if you're only analyzing data in one language or overlooking dominant entities, you may not catch these significant shifts in sentiment until it’s too late.

To tap into this momentum spike, you can use the following Python code to make an API call that filters sentiment data by geographic origin. We’ll set the parameters to focus on English language articles about the topic "world."

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

import requests

# Define parameters for the API call
topic = 'world'
score = +0.027
confidence = 0.85
momentum = +0.262
language_filter = {"lang": "en"}

# Make the API call to get filtered sentiment data
response = requests.post("https://api.pulsebit.com/sentiment", json={
    "topic": topic,
    "score": score,
    "confidence": confidence,
    "momentum": momentum,
    "filters": language_filter
})

# Print the response
print(response.json())
Enter fullscreen mode Exit fullscreen mode

Next, we can leverage the narrative framing of the cluster story to score the sentiment around it. This gives us insights into how the public sentiment is constructed and understood. We’ll send the string describing the cluster reason back through our sentiment analysis endpoint.

# Send the cluster reason through the sentiment endpoint
cluster_reason = "Clustered by shared themes: record, shark, attack, charlie, verco."
sentiment_response = requests.post("https://api.pulsebit.com/sentiment", json={
    "input": cluster_reason
})

# Print the sentiment score for the narrative framing
print(sentiment_response.json())
Enter fullscreen mode Exit fullscreen mode

With these two pieces of code, you can start tracking momentum spikes and understanding the context behind them. Here are three specific builds to consider leveraging this pattern effectively:

  1. Signal Monitoring: Set a threshold for sentiment momentum spikes of +0.25. Use the geo filter to trigger alerts when the threshold is met. This will ensure you're on top of emerging stories well before they hit mainstream.

  2. Meta-Sentiment Analysis: Utilize the meta-sentiment loop to analyze clusters with shared themes. Use the previous example to run narratives through our sentiment analysis and build a sentiment score for each cluster to identify which topics are resonating positively.

  3. Thematic Tracking: Build a monitoring script that tracks forming themes like "world(+0.00)", "new(+0.00)", and "rare(+0.00)" against mainstream narratives. This will let you uncover emerging stories that might be overshadowed by more common topics.

If you want to dive deeper, check our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run these examples in under 10 minutes, giving you immediate access to crucial sentiment insights. Don’t let your pipeline lag behind—stay ahead of the narrative!

Top comments (0)