home

How I built a Hacker News sentiment analyzer more neutral than Switzerland — then managed to fix it

·2 min read

Building a Hacker News Sentiment Analyzer in 30 Minutes: Solving the “Everything is Neutral” Problem

The 30-Minute Challenge

This morning I gave myself a simple challenge: build something that analyzes the mood of the tech community in real-time. The result? A Hacker News sentiment analyzer that fetches top stories and classifies them as positive, negative, or neutral.

What I built:- Real-time HN data fetching via Firebase API- RoBERTa transformer for sentiment analysis - Interactive Streamlit dashboard with charts- Deployed to GitHub: HackerNewsSentiment

The Problem: Everything Was “Neutral”

Here’s where it got interesting. My first attempt classified 48 out of 50 stories as neutral!!! Headlines like “Show HN: Amazing new AI breakthrough” were coming back as neutral, which felt completely wrong.

This is apparently a well-known problem in sentiment analysis. As one HN user put it: ”Most algorithms just predict everything as neutral… An LLM can understand that ‘Bitwarden is the answer’ is a glowing recommendation, not a neutral statement.”

The Solution: Hybrid AI + Rules

Instead of just relying on the model, I built a hybrid approach:


**Override neutral classifications**if any(keyword in title_lower for keyword in positive_keywords): if mapped_label != ‘negative’ or confidence < 0.8: mapped_label = ‘positive’```

**Key insight**: Sometimes you need to add domain knowledge on top of AI models. Pure ML isn’t always the answer.

### Results & Lessons
The hybrid approach dramatically improved results:- **Before**: 48/50 neutral 😴- **After**: ~7 positive, ~30 neutral, ~13 negative 🎯 *(of couse, it could always just be a more neutral kind of day on HN)*

*Finally an *improvement*!***Three key takeaways:**1. I have to s**tart simple. **I got the basic pipeline working first, then optimized2. I have to **question the model**. when results feel wrong, they probably are3. I can always **combine approache**s. AI + rules often beats pure AI for domain-specific problems

### What’s Next?
This “instant momentum” project took exactly 30 minutes to build the core functionality, plus another hour for the anti-neutral fixes. It’s now ready for Streamlit Cloud deployment and perfect for tonight’s social media post.

Sometimes the best projects come from scratching your own itch. I wanted to know the mood of HN discussions — now I have a tool that actually works.

**Try it yourself**: The code is open source and ready to deploy. What would you analyze next?

---

*Originally published on [Medium](https://medium.com/@amazingcwk2/how-i-built-a-hacker-news-sentiment-analyzer-more-neutral-than-switzerland-then-managed-to-fix-it-e60dac73bc9d?source=rss-2c5e11eb11e8------2)*