Introduction
Sentiment analysis is one of the most practical applications of Natural Language Processing (NLP).
In this project, I explore how to perform sentiment analysis on a short story and visualize emotional patterns using Python and Power BI.
The goal is simple: transform raw text into meaningful insights.
In this guide, we’ll walk through how to perform sentiment analysis using NLP step-by-step.
What is Sentiment Analysis in NLP?
Sentiment analysis is a technique used in NLP to determine whether a piece of text expresses a positive, negative, or neutral emotion.
It is widely used in:
- Customer feedback analysis
- Social media monitoring
- Product reviews
In this case, I applied sentiment analysis to a literary text to understand how emotions evolve throughout a story.
Project Idea
Most people read stories…
But what if we could analyze how a story feels?
I used “The Tell-Tale Heart” by Edgar Allan Poe and broke it into smaller segments, then applied sentiment analysis to each part.
This allowed me to track emotional changes across the narrative.
How to Analyze Text Using NLP
The workflow for this project was:
- Load and clean the text
- Split the text into segments
- Apply sentiment analysis
- Generate a structured dataset
- Visualize the results
Here’s a simplified Python example:
from textblob import TextBlob
text = "I felt nervous and terrified."
blob = TextBlob(text)
sentiment = blob.sentiment.polarity
print(sentiment)
This returns a sentiment score that helps classify the emotional tone of the text.
Building a Sentiment Analysis Dataset
After processing the text, I created a dataset like this:
Segment | Label | Score
1 | Positive| 0.91
2 | Negative| 0.45
This step is critical because it transforms unstructured text into structured data that can be analyzed and visualized.
Visualizing Sentiment Analysis Results Using Power BI
Once the dataset was ready, I built a dashboard using Power BI to visualize:
- Emotional trends over time
- Distribution of positive vs negative segments
- Key moments of emotional intensity
Sentiment analysis dashboard using NLP and Power BI

This helped turn raw numbers into a clear emotional narrative.
Key Insights from the Analysis
- The story appears mostly positive overall (~56%)
- However, it contains frequent sharp emotional drops
- These drops align with moments of tension and psychological intensity
This shows that even if a story seems balanced overall, emotional spikes reveal its most impactful moments.
What I Learned
- How to apply sentiment analysis using NLP in a real project
- How to transform text into structured datasets
- How to visualize insights using Power BI
- The importance of storytelling in data analysis
Conclusion
This project demonstrates how sentiment analysis using NLP can go beyond traditional use cases and be applied to creative domains like literature.
By combining NLP with visualization tools, we can better understand how emotions evolve in any text.
Project Links
GitHub Repository: https://github.com/Fadydesoky/ai-story-sentiment-analysis
LinkedIn: https://www.linkedin.com/in/fadydesokysaeedabdelaziz
If you're interested in sentiment analysis using NLP or building real-world data projects, feel free to explore the full project on GitHub or connect with me on LinkedIn.