DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 16.7h Behind: Catching Biotech Sentiment Leads with Pulsebit

Your Pipeline Is 16.7h Behind: Catching Biotech Sentiment Leads with Pulsebit

We recently spotted a striking anomaly: a 24h momentum spike of +1.338 in the biotech sector. This spike caught our attention, particularly because it was led by English press coverage that had a notable 16.7-hour lead over the event itself. The articles clustered around Mazumdar Shaw’s mission to expand access to vital drugs, signaling an important shift in sentiment that your model might have missed if it doesn't account for multilingual origins or entity dominance.

English coverage led by 16.7 hours. Et at T+16.7h. Confidenc
English coverage led by 16.7 hours. Et at T+16.7h. Confidence scores: English 0.95, Spanish 0.95, French 0.95 Source: Pulsebit /sentiment_by_lang.

The Problem

If your pipeline isn’t equipped to handle multilingual data or identify dominant entities, you may have missed this momentum spike by a significant 16.7 hours. The leading language in this case was English, but the sentiment around the topic stretches across various languages. When your model fails to recognize this gap, it risks missing critical shifts in sentiment that can lead to misinformed strategies or delayed responses in a fast-moving environment like biotech.

The Code

Let’s dive into how we can catch this spike using our API. Here’s how you can filter the data based on geographic origin and analyze the narrative framing itself.

First, to filter articles by language, we’ll use the following API call:

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

import requests

# Define parameters
topic = 'biotech'
score = +0.000
confidence = 0.95
momentum = +1.338

# API call to get articles in English
response = requests.get(
    'https://api.pulsebit.com/v1/articles',
    params={
        'topic': topic,
        'lang': 'en',
        'momentum': momentum
    }
)
articles = response.json()
Enter fullscreen mode Exit fullscreen mode

Next, we’ll run the cluster reason string through our sentiment analysis endpoint to evaluate the narrative framing. This is crucial for understanding the sentiment beyond simple metrics:

# Meta-sentiment moment
cluster_reason = "Clustered by shared themes: her, mission, mazumdar-shaw, she, india."

# API call to get sentiment score
sentiment_response = requests.post(
    'https://api.pulsebit.com/v1/sentiment',
    json={'text': cluster_reason}
)

sentiment_score = sentiment_response.json().get('score')
print(f'Meta-sentiment score: {sentiment_score}')
Enter fullscreen mode Exit fullscreen mode

This code not only captures the sentiment spike but also contextualizes it through the narrative themes that drive the sentiment.

Three Builds Tonight

Based on the momentum and sentiment analysis we’ve derived, here are three specific builds to consider:

  1. Geographic Filter: Enhance your pipeline to catch spikes in biotech sentiment specifically in regions where English is the dominant language. Set a threshold for momentum at +1.0 to trigger alerts.

Geographic detection output for biotech. France leads with 1
Geographic detection output for biotech. France leads with 1 articles and sentiment +0.00. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Loop: Implement a loop that feeds the cluster reason back into the sentiment analysis endpoint every time a spike in momentum is detected. This can help you refine the narrative framing continuously. Use a threshold of confidence >= 0.90 for actionable insights.

  2. Forming Themes Analysis: Create a module that tracks forming themes like "her," "mission," and "mazumdar-shaw" against mainstream discourse. Trigger an alert when the sentiment score around these themes deviates significantly from the baseline.

Get Started

You can start building these insights into your workflow in no time. Visit pulsebit.lojenterprise.com/docs to access our API documentation. You’ll be able to copy-paste and run this in under 10 minutes, bringing your sentiment analysis capabilities to the next level.

Top comments (0)