-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFinalScript.py
More file actions
54 lines (42 loc) · 1.56 KB
/
FinalScript.py
File metadata and controls
54 lines (42 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Final File To Run The Script
import pandas as pd
import numpy as np
#Importing Other Python Files
from YouTubeCommentScraper import YouTube_Comment
from PreprocessingData import Clean_Text
from SentimentAndSeverityAnalysis import Function_Sentiment, Function_Severity
#Scraping Comments
url = input("Enter YouTube Link: ")
comments = YouTube_Comment(url) #Returns List
Cleaned_Comments = []
#Preprocessing Data
for comment in comments:
cleaned = Clean_Text(comment)
Cleaned_Comments.append(cleaned)
Sentiment = []
Severity = []
Score = []
for clean in Cleaned_Comments:
senti_score= Function_Sentiment(clean) #Returns Tuple With Sentiment At Index 0 And Score At Index 1
senti = senti_score[0]
scor = senti_score[1]
sever = Function_Severity(clean) #Returns String
Sentiment.append(senti)
Score.append(scor)
Severity.append(sever)
Full_Analytics = pd.DataFrame({
'Comment': comments,
'Sentiment': Sentiment,
'Score': Score,
'Severity': Severity
})
Full_Analytics.to_csv("Analytics.csv")
print("\n")#Leaving A Line To Improve Presentation
print("\n")#Leaving A Line To Improve Presentation
print("Average Score: " , sum(Score)/len(Score))
print("Total Positive Sentiment Comments: ", Sentiment.count('POSITIVE'))
print("Total Negative Sentiment Comments: ", Sentiment.count('NEGATIVE'))
if Sentiment.count('POSITIVE') >=Sentiment.count('NEGATIVE'):
print("Average Severity: Not Severe")
else:
print("Average Severity: ", Function_Severity(sum(Score)/len(Score)))