Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Free: 6-day Agentic AI Engineering Email Guide.
Learnings from Towards AI's hands-on work with real clients.
How I Used Data Journalism and NLP to Analyze Public Opinion on a Viral Political Debate
Latest   Machine Learning

How I Used Data Journalism and NLP to Analyze Public Opinion on a Viral Political Debate

Last Updated on July 30, 2026 by Editorial Team

Author(s): Billy Cemerson

Originally published on Towards AI.

How I Used Data Journalism and NLP to Analyze Public Opinion on a Viral Political Debate

What thousands of YouTube comments reveal about how people react to political narratives, and why data journalism offers a better way to understand them.

Introduction

Every time a controversial political figure appears online, thousands of people rush to the comment section. Some show support. Others criticize. Many argue with each other. Within a few hours, the discussion grows too large for anyone to read manually.

As data practitioners, we often ask questions like these. Is public opinion mostly positive or negative? What emotions dominate the discussion? What issues are people actually talking about? Are people debating policies, personalities, or the media itself?

Answering these questions by reading thousands of comments one by one is simply not realistic. This is exactly the kind of problem that Data Journalism and Natural Language Processing (NLP) can solve together.

In this project, I analyzed more than 8,000 YouTube comments from Tempo’s video discussing Dedi Mulyadi, widely known as KDM. Instead of treating NLP as the final goal, I used it as a journalistic tool to investigate a public conversation and uncover the narratives hidden inside thousands of comments. The dataset contained 8,062 comments posted by 7,409 unique users, giving a rich source for exploring public discourse.

How I Used Data Journalism and NLP to Analyze Public Opinion on a Viral Political Debate
Source: Tempo YouTube Video

This article walks through the project using a simple Data Journalism workflow, moving from an initial question all the way to evidence based insights.

Why Data Journalism

When people hear the term data science, they often picture machine learning models or dashboards. Data journalism starts from a slightly different place. It begins with a question.

Instead of asking which model has the highest accuracy, data journalism asks what story is hidden inside the data. The technology is only a tool. The real goal is to investigate an issue using evidence.

Throughout this project, I followed a workflow similar to the one many data journalists use. First comes the story idea. Then comes collecting the data. After that, the data must be cleaned and prepared. Only then does real analysis begin, followed by visualization, and finally the story itself is told.

The Question Behind This Project

The project began with curiosity rather than code.

Dedi Mulyadi, known as KDM, has become one of Indonesia’s most discussed political figures. Since becoming Governor of West Java, several of his policies have caused public debate. These include sending troubled students to military style camps, banning school graduation ceremonies, and proposing vasectomy as a requirement for certain social assistance programs. At the same time, his frequent media presence has attracted both loyal supporters and sharp critics.

Tempo later published a YouTube video presenting its own perspective and criticism of KDM. That video sparked a large discussion in the comment section.

Rather than debating whether Tempo or KDM was right, I wanted to look at something different. How do people actually respond to this kind of discussion?

More specifically, I wanted to know if comments were mostly supportive or critical, what emotions dominated the conversation, which topics kept repeating, and whether the discussion centered on policies, leadership, or the media narrative itself.

It is worth saying clearly that this project does not try to decide who is politically right. It simply examines how people reacted, based on public YouTube comments.

Phase 1: Collecting the Evidence

The comment section of Tempo’s video became the main source of evidence because it captured thousands of spontaneous reactions from viewers who were all responding to the same event. Instead of relying on a handful of opinions, this dataset offers a much wider picture of how people actually responded.

To collect the data, I used the YouTube Data API version 3, which allows developers to retrieve publicly available information such as comments, usernames, publication times, and engagement numbers like likes.

Instead of manually copying comments one at a time, which would be slow and hard to repeat, the API provided a structured and automated way to gather everything needed.

By the end of this stage, the dataset contained 8,062 comments, 7,409 unique users, along with comment text, usernames, like counts, and timestamps. This amount of information would be nearly impossible to analyze by hand, which made it an ideal case for Natural Language Processing.

Phase 2: Cleaning the Conversation

Collecting data is often the easiest part of a data journalism project. Preparing it properly is where most of the real work happens.

Anyone who has read YouTube comments knows why. Some people write full sentences. Others write only emojis. Many use internet slang. Some repeat letters for emphasis, like writing “mantappppp” instead of “mantap.” Others mix uppercase and lowercase letters, abbreviations, and regional expressions all in the same sentence.

Humans understand these variations easily. Machine learning models do not. For a computer, “setujuuu bangettt” and “setuju” look like two completely different pieces of text, even though they mean the same thing.

Before asking any analytical questions, the text had to be standardized. The cleaning process for this project included several steps. Duplicate records were removed. Text was converted to lowercase. Comments were tokenized, meaning broken into individual words. Text was normalized so that slang and repeated letters were reduced to their standard form. Common stopwords, meaning frequent but low meaning words, were removed. Finally, stemming was applied using a tool called Sastrawi, along with general cleanup using NLTK.

This process does not change what people actually said. It simply converts many different writing styles into one consistent form that algorithms can read properly.

Phase 3: Turning Comments into Evidence

After the dataset was cleaned, I finally reached the stage most people associate with NLP, which is analysis. But before choosing any model, I returned to the original questions. What exactly was I trying to understand?

One single NLP technique cannot answer every question on its own. So I split the investigation into three separate angles. What do people think? That question is answered through sentiment analysis. What do people feel? That question is answered through emotion analysis. What are people actually discussing? That question is answered through topic modeling.

Each of these techniques answers a different part of the puzzle, and together they build a much fuller picture of the public conversation.

What Do People Think

The first and simplest question was whether people were generally supportive or critical. To answer this, I used sentiment analysis powered by an Indonesian language model called IndoRoBERTa, which classifies text as positive, neutral, or negative.

The results showed an interesting contrast. Comments that focused on KDM were mostly negative, while comments about Tempo itself were spread more evenly across positive, neutral, and negative sentiment.

Download the Medium app

At first glance, this might suggest that public opinion leaned strongly against KDM. But sentiment analysis only tells us whether a comment sounds positive or negative. It does not explain why. A comment complaining that KDM is only doing image building, and a separate comment complaining that Tempo is being unfair to KDM, could both be labeled as negative sentiment, even though they criticize completely different things. This shows why sentiment alone is never the full story.

What Do People Feel

Knowing whether a comment is positive or negative is useful, but human communication carries much more nuance than that. Someone can express criticism through anger. Another person can express concern through sadness. Someone else might celebrate with genuine happiness.

To explore this layer, I applied emotion analysis, again using an Indonesian transformer model trained to detect specific emotional categories in text.

Anger emerged as the dominant emotion across the entire discussion. Comments related to Tempo were overwhelmingly angry in tone, while comments related to KDM showed a stronger mix of anger and happiness together.

This finding matters because people participating in political discussions online are usually not simply evaluating policy in a calm, neutral way. They are expressing frustration, defending their beliefs, or celebrating a political figure they support. For journalists, understanding this emotional layer matters because emotional reactions often shape how information spreads and how audiences continue to engage with a story.

What Are People Talking About

If we know that people are angry, the next natural question is what is actually causing that anger. Sentiment analysis cannot answer that. Emotion analysis cannot answer it either.

To uncover the themes hiding behind thousands of individual comments, I used topic modeling with a method called IndoBERTopic. Rather than counting single words, this method groups comments with similar meaning into broader themes or discussion clusters.

One topic clearly dominated the overall discussion, while two smaller topics captured more specific viewpoints. When looking closely at the keywords inside these topics, some themes came up again and again. These included the idea of image building, general content and media coverage, and comparisons to other political leaders such as Jokowi.

Rather than debating detailed policy specifics, many commenters were really questioning leadership style, public image, and the media narrative surrounding KDM as a whole.

Putting the Three Together

Each of these three methods answers a different part of the same question. Sentiment analysis alone would only tell us that many comments were negative, without explaining why. Emotion analysis alone would tell us that anger was common, without explaining what triggered it. Topic modeling fills in that missing piece by revealing the actual narratives sitting underneath those emotions.

Together, these three methods turned more than 8,000 individual comments into real evidence that can be interpreted as part of a much larger public conversation.

Phase 4: From Analysis to Storytelling

At this point, the technical work was essentially finished. The comments had been collected. The text had been cleaned. Sentiment, emotion, and discussion topics had all been analyzed. But one important question still remained. So what does all this actually mean?

This is exactly where data journalism differs from a typical data science exercise. A machine learning model produces predictions. A data journalism project produces understanding. The responsibility of the analyst is not only to build something technically accurate, but to interpret the results responsibly and explain them in a way that helps readers see the bigger picture.

Looking at the three analyses together tells a more complete story than any single chart could tell on its own. Sentiment analysis suggested that KDM attracted more negative opinions overall. Emotion analysis added an important layer by showing that many of those reactions were driven by real anger rather than calm disagreement. Topic modeling completed the picture by showing that the anger was mostly tied to leadership image, media coverage, and comparisons with past political figures, rather than any single isolated event.

Taken together, this suggests the conversation was never really just about one YouTube video. It reflected a much broader public debate about political leadership, media trust, and public image in Indonesia today. That pattern is difficult to notice by reading comments one at a time, but it becomes much clearer once thousands of comments are examined together as a whole.

Why This Matters for Different People

For journalists, this kind of analysis can help identify which issues genuinely resonate with an audience and where further reporting might be needed. For public officials and their teams, public comments can act as an early warning signal about concerns or misunderstandings that deserve closer attention. For communication teams more broadly, understanding the emotions behind public reactions supports more thoughtful messaging, instead of simply reacting to raw engagement numbers like views or likes.

Even within this project’s own recommendations, the suggestions point toward shifting from symbolic gestures toward measurable outcomes, encouraging fairer and more balanced reporting, and building real channels for public dialogue instead of one way communication.

The goal of all this was never to replace human judgment with an algorithm. It was to support that judgment with real evidence.

Being Honest About Limitations

Like every data project, this investigation has real limitations that are worth stating clearly.

First, this analysis is based on comments from a single YouTube video. Even though the dataset contains thousands of responses, it does not represent every Indonesian’s opinion.

Second, online comments often include sarcasm, irony, and casual jokes. Even strong language models can still misread these kinds of nuances.

Third, YouTube comments only represent people who actually chose to participate in the discussion. People who watched silently, or people discussing the topic elsewhere, may hold very different views.

Finally, sentiment analysis measures the emotional tone of a comment. It does not measure whether the underlying claim in that comment is actually true or false.

Being honest about these limitations is part of doing this kind of work responsibly. Transparency is what builds trust in the findings.

What I Learned

Before starting this project, I thought Natural Language Processing was mainly about building models that classify text as accurately as possible. After finishing it, I realized NLP becomes far more powerful once it is combined with a journalistic mindset.

The most valuable part of this project was not achieving high model accuracy. It was learning how to turn thousands of scattered opinions into one structured, understandable investigation.

The process kept returning to the same simple sequence. Start with a question that actually matters. Collect reliable evidence. Prepare that evidence carefully. Analyze it from more than one angle. Then communicate the findings honestly and responsibly.

That sequence reflects the core idea behind both data journalism and data analytics in general. The tools may change over time, moving from spreadsheets to Python, or from simple keyword counts to transformer models, but the underlying goal always stays the same. Use data to help people understand the world around them a little bit better.

Conclusion

When public discussions move online, they leave behind an enormous trail of digital evidence. Every comment, every reply, and every reaction becomes part of a much larger conversation, one that is nearly impossible to fully understand just by reading through it manually.

This project shows how Data Journalism and Natural Language Processing can work together to close that gap. By analyzing more than 8,000 YouTube comments, the goal was never to decide who was politically right or wrong. Instead, the goal was to understand how people reacted, what emotions shaped that reaction, and which narratives kept appearing again and again throughout the conversation.

Perhaps the biggest lesson from this whole project is that NLP did not tell the story by itself. It helped reveal the patterns hiding inside the data. The real story only appeared once those patterns were interpreted with context, careful thinking, and an understanding of the wider social conversation happening around them.

Full notebook, code, and datasets are available on GitHub: github.com/billycemerson/kdm-tempo-nlp

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI


Towards AI Academy

We Build Enterprise-Grade AI. We'll Teach You to Master It Too.

15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.

Start free — no commitment:

6-Day Agentic AI Engineering Email Guide — one practical lesson per day

Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages

Our courses:

AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.

Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.

AI for Work — Understand, evaluate, and apply AI for complex work tasks.

Note: Article content contains the views of the contributing authors and not Towards AI.