Python 3 Sentiment Text Analysis Project Using Machine Learning Models & NLTK ChatGPT Library
70 views
Jun 3, 2025
Get the full source code of application here: https://codingshiksha.com/python/python-3-sentiment-text-analysis-project-using-machine-learning-models-nltk-chatgpt-library/
View Video Transcript
0:00
uh hello guys welcome to this video So
0:02
in this video I will show you how to do
0:05
sentimental uh analysis of any sort of
0:08
sentence
0:10
uh in English language using uh uh
0:15
machine learning models and uh national
0:18
uh natural language processing chart GPT
0:21
library So inside Python we can actually
0:24
do sentimental analysis of sentences
0:27
that whether a sentence is positive
0:29
negative neutral what is the tone of the
0:31
sentence So we have this bas basically
0:33
this uh Python script here We have a
0:36
series of sentences that I have written
0:38
right here Uh so you will see it will
0:42
exactly tell you the tone of the
0:44
sentence So we have three sentences
0:46
right here I know in my heart nobody
0:48
comes close to me and I am the greatest
0:51
player in the world So this is actually
0:52
a positive kind of a sentence Let me
0:55
first of all show you if I execute this
0:57
Python script what is the output that
1:00
I'm getting So first of all you need to
1:02
install this module here which is Vader
1:07
sentimental So the command is simple You
1:10
simply say pip install uh
1:15
vader
1:17
sentiment So you simply install this
1:19
module I have
1:21
uh you just need to execute this command
1:24
So this will hardly take 5 to 10 seconds
1:27
and it will install this and after that
1:29
you just need to execute this command
1:32
here and exactly it will tell you the
1:34
sentiment and analysis of each sentence
1:37
it will give you a score based upon the
1:40
tone of the sentence So you can see the
1:42
first statement has a negative sentiment
1:45
of uh 0% and a neutral sentiment of
1:49
65.6% and a positive sentiment of
1:53
34.4% So overall sentiment is positive
1:56
The second statement that I have taken
2:00
this example if you see Shaa played well
2:02
in the match as usual So this is a again
2:06
a positive kind of
2:08
a sentiment and it has given me the
2:11
positive rating which is
2:14
42.9% And the third sentence is negative
2:17
as you can see negative sentiment is 40%
2:20
and neutral is 39% And the sentence was
2:23
if you see I am feeling sad today So
2:25
this is actually a kind of a negative
2:28
kind of a sentence So in this easy way
2:31
using this free module of Python you can
2:34
actually do the
2:35
sentiment
2:37
analysis So the module is very simple
2:40
You simply install this module pip
2:43
install Vader
2:46
sentiment So install this It uses
2:49
machine learning models and
2:52
NLTKJ chart GPT library in the
2:55
background I've given all the source
2:57
code in the description of the video So
2:59
now I will show you just create a simple
3:02
Python file and then from Vader
3:05
sentiment you just need to import Vader
3:07
sentiment and from this you need to
3:11
import sentiment intensity
3:15
analyzer After
3:17
that we will define a simple function
3:20
which will give the sentiment scores
3:24
based upon the
3:26
sentence given as an
3:31
argument So here we will
3:34
basically create an object here
3:36
initializing the sentiment and intensity
3:39
analyzer After
3:42
that we will basically make a dictionary
3:46
based upon
3:51
the
3:54
sid and it contains this function here
3:57
which
3:59
is
4:01
polarity scores So it will give you the
4:03
scores here based upon the sentence
4:05
which is given
4:12
And then you can print out the scores
4:14
here
4:27
So we are printing out this dictionary
4:29
based upon it contains three kind of
4:32
score negative neutral and
4:36
positive And uh now we just need to call
4:40
this function So we will basically take
4:44
three examples of
4:47
sentences So I will call this function
4:50
inside the main function So right here
4:52
we are providing three sentences again
4:55
you will see I know in my heart nobody
4:56
comes close and I'm the greatest player
4:58
in the world I am feeling sad today and
5:01
Shwa played well
5:04
in so if you run this script
5:10
here it is saying underscore object is
5:13
not
5:14
defined set object
5:32
set unis
5:36
code I've given all this
5:40
uh source code in the description of the
5:43
video guys So if you need the full
5:45
source code the link is given in the
5:47
description
5:49
So so now I fixed this It's just a typo
5:53
mistake And if I refresh it you will see
5:55
that it will give you these three
5:59
scores Percentages negative sentiment
6:02
neutral positive the percentages it will
6:05
give you the sentiment analysis of each
6:08
sentence So in this easy way you can use
6:11
this free module inside Python to
6:14
actually do the sentiment analysis of
6:16
each sentence You can basically give any
6:18
sentence of English language and based
6:20
upon that it will give you these
6:22
percentages of neutral positive negative
6:25
like this So thank you very much for
6:28
watching this video and also check out
6:29
my website freemediattools.com
6:32
uh which contains thousands of tools