Demea9000 commited on
Commit
c91c79b
1 Parent(s): 389ca88

made runnable

Browse files
Files changed (1) hide show
  1. textclassifier/TextClassifier.py +4 -7
textclassifier/TextClassifier.py CHANGED
@@ -66,7 +66,7 @@ class TextClassifier:
66
  """
67
  df_sentiment = self.ts.scrape_by_user(user_name)
68
  df_sentiment['sentiment'] = df_sentiment['tweet'].apply(self.classify_sentiment)
69
- self.df = df_sentiment
70
 
71
  def analyze_sentiment(self, text: str, sentiment: str):
72
  """
@@ -142,14 +142,11 @@ class TextClassifier:
142
  """
143
 
144
  def __repr__(self):
145
- if self.df is None:
146
- return "No dataframe available."
147
- else:
148
- return self.df.to_string()
149
 
150
 
151
  if __name__ == "__main__":
152
  tc = TextClassifier(model_name="text-davinci-002", from_date='2022-01-01', to_date=str(date.today()), num_tweets=20)
153
  print(tc)
154
- tc.classify_sentiment_of_tweets("jimmieakesson")
155
- print(tc)
 
66
  """
67
  df_sentiment = self.ts.scrape_by_user(user_name)
68
  df_sentiment['sentiment'] = df_sentiment['tweet'].apply(self.classify_sentiment)
69
+ return df_sentiment
70
 
71
  def analyze_sentiment(self, text: str, sentiment: str):
72
  """
 
142
  """
143
 
144
  def __repr__(self):
145
+ return "TwitterScraper(from_date={}, to_date={}, num_tweets={})".format(self.from_date, self.to_date, self.num_tweets)
 
 
 
146
 
147
 
148
  if __name__ == "__main__":
149
  tc = TextClassifier(model_name="text-davinci-002", from_date='2022-01-01', to_date=str(date.today()), num_tweets=20)
150
  print(tc)
151
+ df = tc.classify_sentiment_of_tweets("jimmieakesson")
152
+ print(df)