wira.indra commited on
Commit
39d5762
1 Parent(s): d84c978

add twitter feature

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -76,14 +76,10 @@ def twitter_analyzer(keyword, max_tweets):
76
  df = ts.scrape_tweets(keyword, max_tweets=max_tweets)
77
  df["Text"] = df["Text"].apply(ts.preprocess_text)
78
  df = sentiment_df(df)
 
79
  fig = plt.figure()
80
  df.groupby(["Label"])["Text"].count().plot.pie(autopct="%.1f%%", figsize=(6,6))
81
- return fig, df[["URL", "Text", "Label", "Score"]]
82
-
83
- def ner_analyzer(keyword, df_ner):
84
- df_ner = df_ner[df_ner.line_race != keyword]
85
- fig = plt.figure()
86
- return fig
87
 
88
  if __name__ == "__main__":
89
 
@@ -123,10 +119,17 @@ if __name__ == "__main__":
123
  overflow_row_behaviour='paginate',
124
  wrap=True)
125
 
 
 
 
 
 
 
 
126
  analyze_button.click(sentiment_ner, input_text, [sent_output, ner_output])
127
  submit_button.click(twitter_analyzer,
128
  inputs=[keyword_textbox, max_tweets_component],
129
- outputs=[plot_component, dataframe_component])
130
 
131
  gr.Markdown(
132
  """
 
76
  df = ts.scrape_tweets(keyword, max_tweets=max_tweets)
77
  df["Text"] = df["Text"].apply(ts.preprocess_text)
78
  df = sentiment_df(df)
79
+ df_ner = ner_df(df)
80
  fig = plt.figure()
81
  df.groupby(["Label"])["Text"].count().plot.pie(autopct="%.1f%%", figsize=(6,6))
82
+ return fig, df[["URL", "Text", "Label", "Score"]], df_ner
 
 
 
 
 
83
 
84
  if __name__ == "__main__":
85
 
 
119
  overflow_row_behaviour='paginate',
120
  wrap=True)
121
 
122
+ df_ner = gr.DataFrame(type="pandas",
123
+ label="Dataframe",
124
+ max_rows=(20,'fixed'),
125
+ overflow_row_behaviour='paginate',
126
+ wrap=True)
127
+
128
+
129
  analyze_button.click(sentiment_ner, input_text, [sent_output, ner_output])
130
  submit_button.click(twitter_analyzer,
131
  inputs=[keyword_textbox, max_tweets_component],
132
+ outputs=[plot_component, dataframe_component, df_ner])
133
 
134
  gr.Markdown(
135
  """