Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2374634

Browse files
committed
added sentiment analysis using vader tutorial
1 parent67b14ec commit2374634

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
3535
- [How to Build a Spam Classifier using Keras in Python](https://www.thepythoncode.com/article/build-spam-classifier-keras-python). ([code](machine-learning/nlp/spam-classifier))
3636
- [How to Build a Text Generator using TensorFlow and Keras in Python](https://www.thepythoncode.com/article/text-generation-keras-python). ([code](machine-learning/nlp/text-generator))
3737
- [How to Perform Text Classification in Python using Tensorflow 2 and Keras](https://www.thepythoncode.com/article/text-classification-using-tensorflow-2-and-keras-in-python). ([code](machine-learning/nlp/text-classification))
38+
- [Sentiment Analysis using Vader in Python](https://www.thepythoncode.com/article/vaderSentiment-tool-to-extract-sentimental-values-in-texts-using-python). ([code](machine-learning/nlp/sentiment-analysis-vader))
3839
-###[Computer Vision](https://www.thepythoncode.com/topic/computer-vision)
3940
-[How to Detect Human Faces in Python using OpenCV](https://www.thepythoncode.com/article/detect-faces-opencv-python). ([code](machine-learning/face_detection))
4041
-[How to Make an Image Classifier in Python using TensorFlow and Keras](https://www.thepythoncode.com/article/image-classification-keras-python). ([code](machine-learning/image-classifier))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[Sentiment Analysis using Vader in Python](https://www.thepythoncode.com/article/vaderSentiment-tool-to-extract-sentimental-values-in-texts-using-python)
2+
-`pip3 install -r requirements.txt`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vaderSentiment
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fromvaderSentiment.vaderSentimentimportSentimentIntensityAnalyzer
2+
3+
# init the sentiment analyzer
4+
sia=SentimentIntensityAnalyzer()
5+
6+
sentences= [
7+
"This food is amazing and tasty !",
8+
"Exoplanets are planets outside the solar system",
9+
"This is sad to see such bad behavior"
10+
]
11+
12+
forsentenceinsentences:
13+
score=sia.polarity_scores(sentence)["compound"]
14+
print(f'The sentiment value of the sentence :"{sentence}" is :{score}')
15+
16+
forsentenceinsentences:
17+
print(f'For the sentence "{sentence}"')
18+
polarity=sia.polarity_scores(sentence)
19+
pos=polarity["pos"]
20+
neu=polarity["neu"]
21+
neg=polarity["neg"]
22+
print(f'The percententage of positive sentiment in :"{sentence}" is :{round(pos*100,2)} %')
23+
print(f'The percententage of neutral sentiment in :"{sentence}" is :{round(neu*100,2)} %')
24+
print(f'The percententage of negative sentiment in :"{sentence}" is :{round(neg*100,2)} %')
25+
print("="*50)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp