DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 18.3h Behind: Catching Agriculture Sentiment Leads with Pulsebit

Your Pipeline Is 18.3h Behind: Catching Agriculture Sentiment Leads with Pulsebit

We just uncovered a striking anomaly: a 24-hour momentum spike of +0.167 in sentiment towards agriculture. This is a significant shift that highlights a surge in positive sentiment, particularly focused on U.S. agricultural concerns as we move into the harvest season. With just two articles clustered around this topic, the implications are clear: there's a wave of sentiment that your analytics might be missing.

The problem here is glaring. If your model isn't equipped to handle multilingual origins or entity dominance, you're likely running behind. In our case, you would have missed this sentiment spike by 18.3 hours! This means that while we were monitoring English-language articles, you were potentially sidelined, losing out on critical insights from the U.S. market, where we observed an 11% share of voice and a positive sentiment score of +0.188.

English coverage led by 18.3 hours. Da at T+18.3h. Confidenc
English coverage led by 18.3 hours. Da at T+18.3h. Confidence scores: English 0.90, French 0.90, Spanish 0.90 Source: Pulsebit /sentiment_by_lang.

Here's how we can catch this momentum spike using our API effectively. First, let’s filter by geographic origin and language. We’ll query articles specifically related to agriculture in English.

Geographic detection output for agriculture. India leads wit
Geographic detection output for agriculture. India leads with 4 articles and sentiment +0.62. Source: Pulsebit /news_recent geographic fields.

import requests

# Define parameters
topic = 'agriculture'
momentum = +0.167
confidence = 0.90
lang = 'en'

# API call to fetch articles based on language and topic
response = requests.get(
    f'https://api.pulsebit.com/articles?topic={topic}&lang={lang}'
)
articles = response.json()
Enter fullscreen mode Exit fullscreen mode

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

Next, we can run the meta-sentiment moment to analyze the narrative framing of the clustered articles. This is where we take the cluster reason string and send it back through our sentiment analysis endpoint.

# Define cluster reason string
cluster_reason = "Clustered by shared themes: agriculture, secretary, says, farm, bill."

# API call to analyze sentiment of the cluster reason
sentiment_response = requests.post(
    'https://api.pulsebit.com/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

Now that we have both the articles and the meta-sentiment score, we can make informed decisions based on this newfound momentum.

Here are three specific things to build with this pattern:

  1. Signal Alert System: Create an alert that triggers when sentiment momentum exceeds a threshold of +0.150 for the agriculture topic. This ensures you’re always informed about significant shifts in sentiment.

  2. Geo-Sentiment Dashboard: Set up a dashboard that visualizes sentiment scores for agriculture across various regions, using our geographic origin filter to highlight U.S. sentiment. This allows you to compare local sentiment against the mainstream narrative.

  3. Sentiment Analysis Reports: Generate automated reports that utilize the meta-sentiment loop, focusing on clustering reasons like "agriculture, secretary, says." This not only gives you insights into current themes but also historical comparisons to visualize shifts over time.

If you want to leverage this powerful functionality, head over to our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run this code in under 10 minutes to start capturing sentiment momentum effectively.

Top comments (0)