ThanaphonJoe commited on
Commit
9d64903
·
verified ·
1 Parent(s): b234a25
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -165,6 +165,12 @@ def pretty_output(lines, sentiment):
165
  txt_neg += tmp
166
 
167
  return(txt_pos, txt_neu, txt_neg, fig)
 
 
 
 
 
 
168
  def combine(a, b):
169
  data = pd.DataFrame()
170
  embedded_url = ''
@@ -176,9 +182,19 @@ def combine(a, b):
176
  print(text001)
177
 
178
  if not lines:
179
- fig = plt.plot()
180
- plt.title = 'CANNOT LOAD VDO'
181
- return ("","","",fig)
 
 
 
 
 
 
 
 
 
 
182
  data['text'] = lines
183
  data = clean_me(data)
184
  a = data['wordseged_space_text'][0] + ' SENTIMENT: '
@@ -213,7 +229,6 @@ with gr.Blocks() as demo:
213
  txt_NEG = gr.Textbox(value="", label="Negative comments")
214
  txt_NEU = gr.Textbox(value="", label="Neutral comments")
215
  txt_POS = gr.Textbox(value="", label="Positive comments")
216
-
217
 
218
  btn.click(combine, inputs=[txt, txt_2], outputs=[HTM, txt_POS, txt_NEU, txt_NEG, plot])
219
 
 
165
  txt_neg += tmp
166
 
167
  return(txt_pos, txt_neu, txt_neg, fig)
168
+
169
+ def fx(t):
170
+ return 16 * np.sin(t) ** 3
171
+ def fy(t):
172
+ return 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t)
173
+
174
  def combine(a, b):
175
  data = pd.DataFrame()
176
  embedded_url = ''
 
182
  print(text001)
183
 
184
  if not lines:
185
+ t = np.linspace(-2 * np.pi, 2 * np.pi)
186
+ xs = fx(t)
187
+ ys = fy(t)
188
+ plt.plot(xs, ys, "o")
189
+ plt.title('My Heart')
190
+ plt.xlabel(' CANNOT LOAD VDO ')
191
+ plt.ylabel(' CANNOT LOAD VDO ')
192
+
193
+ str_output ='www.youtube.com/embed/MdSDXZ_zzU'
194
+
195
+ embed_html = f'<center> <iframe id="ytplayer" type="text/html" width="560" height="315" src="{str_output}" frameborder="0" allowfullscreen </iframe> </center>'
196
+
197
+ return (embed_html,"","","", plt.gcf())
198
  data['text'] = lines
199
  data = clean_me(data)
200
  a = data['wordseged_space_text'][0] + ' SENTIMENT: '
 
229
  txt_NEG = gr.Textbox(value="", label="Negative comments")
230
  txt_NEU = gr.Textbox(value="", label="Neutral comments")
231
  txt_POS = gr.Textbox(value="", label="Positive comments")
 
232
 
233
  btn.click(combine, inputs=[txt, txt_2], outputs=[HTM, txt_POS, txt_NEU, txt_NEG, plot])
234