DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 25.9h Behind: Catching Inflation Sentiment Leads with Pulsebit

Your Pipeline Is 25.9h Behind: Catching Inflation Sentiment Leads with Pulsebit

We recently discovered something intriguing: our sentiment score for inflation is sitting at a surprising +0.00 with a momentum of +0.00, revealing a gap of 25.9 hours behind the leading English press. This anomaly indicates that our models might not be picking up on critical market signals in real-time. When sentiment scores sit stagnant, it often masks underlying shifts that could be pivotal for decision-making.

The problem becomes evident when you realize that your model missed this significant lead by 25.9 hours, primarily driven by the dominant English language source reporting on inflation. With the New York Times highlighting Japan's rate hikes to combat inflation, you may find your insights lagging due to a lack of multilingual processing or entity dominance in your pipeline. Ignoring these factors can leave you out of sync with crucial economic trends.

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

Here’s the Python code to help you catch this lead. We'll start by querying our API for articles related to inflation, filtered by English language:

import requests

# Define parameters for API call
topic = 'inflation'
lang = 'en'
url = f'https://api.pulsebit.com/v1/articles?topic={topic}&lang={lang}'

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


response = requests.get(url)
data = response.json()

# Checking the response
print(data)
Enter fullscreen mode Exit fullscreen mode

Now, let's run the meta-sentiment moment to assess the narrative framing. We will send the cluster reason string through our sentiment endpoint:

cluster_reason = "Clustered by shared themes: inflation, raises, rates, 31-year, high."
sentiment_url = 'https://api.pulsebit.com/v1/sentiment'

payload = {
    "text": cluster_reason,
    "confidence": 0.75
}

sentiment_response = requests.post(sentiment_url, json=payload)
sentiment_data = sentiment_response.json()

# Output the sentiment assessment
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

These two code snippets are essential for understanding how to catch up with the leading sentiment trends around inflation.

Now, let’s explore three specific builds you can implement with this newfound data. First, leverage the geographic origin filter to create alerts for inflation-related articles in English, focusing on a threshold of sentiment score above +0.00. This allows you to act on emerging trends swiftly.

Geographic detection output for inflation. India leads with
Geographic detection output for inflation. India leads with 2 articles and sentiment -0.60. Source: Pulsebit /news_recent geographic fields.

Secondly, utilize the meta-sentiment loop to aggregate articles that display a transition from neutral to positive sentiment. Set a threshold where the confidence score is greater than 0.75, allowing you to focus on narratives that are likely to influence decision-making.

Finally, create a signal-based endpoint that tracks forming themes like "high" sentiment against mainstream language such as "could" and "look." This could provide valuable insights into how mainstream narratives are framing important topics.

If you want to dive deeper and start implementing these insights, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the provided code and run this in under 10 minutes, making it easy to catch up with the evolving sentiment landscape around inflation.

Top comments (0)