-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSUI-YT-Ensemble.py
More file actions
48 lines (43 loc) · 1.58 KB
/
SUI-YT-Ensemble.py
File metadata and controls
48 lines (43 loc) · 1.58 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
#!/bin/python
import streamlit as st
import pandas as pd
import numpy as np
import time, os
import matplotlib.pyplot as plt
st.title("Emotion Mining from YouTube video")
URL = st.text_input("Enter youtube URL", "")
plt.style.use('seaborn-white')
os.system("rm sentData.txt")
if st.button('Start Mining'):
os.system(f"./start-vsm-ensemble.sh '{URL}'&")
chart = st.empty()
counter = 0
chart_data = pd.DataFrame(np.array([[0, 0, 0, 0, 0]]), columns=["anger", "disgust", "fear", "joy", "sadness"])
while (1):
try:
f = open("sentData.txt")
break
except:
pass
while (1):
EmocounT = {"anger": 0,
"disgust": 0,
"fear": 0,
"joy": 0,
"sadness": 0}
buff = f.readline()
buff = buff.strip()
if buff != "":
EmocounT[buff] += 1
chart_data.loc[counter] = pd.DataFrame(np.array(
[[EmocounT["anger"], EmocounT["disgust"], EmocounT["fear"], EmocounT["joy"], EmocounT["sadness"]]]), \
columns=["anger", "disgust", "fear", "joy", "sadness"]).loc[0]
plot_data = pd.DataFrame(chart_data.sum())
# chart.bar_chart(chart_data,orientation='vertical')
groups = plot_data.groupby(plot_data.index)
fig, ax = plt.subplots()
for name, group in groups:
ax.bar(name, group[0], label=name, align='center')
chart.pyplot(fig)
time.sleep(0.5)
counter += 1