Spaces:
Running
Running
Commit
·
7ac98e2
1
Parent(s):
bf57957
Update app.py
Browse files
app.py
CHANGED
@@ -117,10 +117,11 @@ def unavailable(input_file, input_checks):
|
|
117 |
return gr.update(value=output, label="Oops!", visible=True)
|
118 |
|
119 |
def file(input_file, input_checks):
|
120 |
-
output = "output.txt"
|
121 |
-
f = open(output, 'w')
|
122 |
-
f.write("The predictions come here.")
|
123 |
-
f.close()
|
|
|
124 |
if "emotion frequencies" in input_checks:
|
125 |
return gr.update(value=output, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
|
126 |
elif "emotion distribution over time" in input_checks:
|
@@ -133,9 +134,25 @@ def file(input_file, input_checks):
|
|
133 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
134 |
|
135 |
def freq(output_file, input_checks):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
simple = pd.DataFrame({
|
137 |
-
|
138 |
-
|
139 |
|
140 |
domain = ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']
|
141 |
range_ = ['#999999', '#b22222', '#663399', '#ffcc00', '#db7093', '#6495ed']
|
|
|
117 |
return gr.update(value=output, label="Oops!", visible=True)
|
118 |
|
119 |
def file(input_file, input_checks):
|
120 |
+
#output = "output.txt"
|
121 |
+
#f = open(output, 'w')
|
122 |
+
#f.write("The predictions come here.")
|
123 |
+
#f.close()
|
124 |
+
output = "showcase/data.txt"
|
125 |
if "emotion frequencies" in input_checks:
|
126 |
return gr.update(value=output, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
|
127 |
elif "emotion distribution over time" in input_checks:
|
|
|
134 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
135 |
|
136 |
def freq(output_file, input_checks):
|
137 |
+
#simple = pd.DataFrame({
|
138 |
+
#'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
|
139 |
+
#'Frequency': [10, 8, 2, 15, 3, 4]})
|
140 |
+
|
141 |
+
f = open("showcase/data.txt", 'r')
|
142 |
+
data = f.read().split("\n")
|
143 |
+
f.close()
|
144 |
+
data = [line.split("\t") for line in data[1:-1]]
|
145 |
+
|
146 |
+
freq_dict = {}
|
147 |
+
for line in data:
|
148 |
+
if line[1] not in freq_dict.keys():
|
149 |
+
freq_dict[line[1]] = 1
|
150 |
+
else:
|
151 |
+
freq_dict[line[1]] += 1
|
152 |
+
|
153 |
simple = pd.DataFrame({
|
154 |
+
'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
|
155 |
+
'Frequency': [freq_dict['neutral'], freq_dict['anger'], freq_dict['fear'], freq_dict['joy'], freq_dict['love'], freq_dict['sadness']]})
|
156 |
|
157 |
domain = ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']
|
158 |
range_ = ['#999999', '#b22222', '#663399', '#ffcc00', '#db7093', '#6495ed']
|