Spaces:
Runtime error
Runtime error
removed some more
Browse files
textclassifier/TextClassifier.py
CHANGED
@@ -59,30 +59,6 @@ class TextClassifier:
|
|
59 |
# self.api_key = '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'
|
60 |
openai.api_key = OPENAI_API_KEY
|
61 |
|
62 |
-
@staticmethod
|
63 |
-
def cleanup_sentiment_results(classification_unclean):
|
64 |
-
"""
|
65 |
-
Cleans up the results of the sentiment classification.
|
66 |
-
:param classification_unclean: string of the classification result.
|
67 |
-
:return: cleaned up string.
|
68 |
-
"""
|
69 |
-
classification_clean = classification_unclean.replace('\n\n', "")
|
70 |
-
classification_clean = classification_clean.replace('\n', "")
|
71 |
-
if classification_clean.startswith(" "):
|
72 |
-
classification_clean = classification_clean.replace(" ", "")
|
73 |
-
|
74 |
-
return classification_clean
|
75 |
-
|
76 |
-
def classify_topics_of_tweets(self):
|
77 |
-
"""
|
78 |
-
Classifies the topics of a user's tweets.
|
79 |
-
"""
|
80 |
-
df_topic = self.df.copy()
|
81 |
-
df_topic['topics'] = df_topic['tweet'].apply(self.classify_topic)
|
82 |
-
self.df = df_topic
|
83 |
-
self.split_topics_into_columns()
|
84 |
-
return self.df
|
85 |
-
|
86 |
def classify_all(self, tweet: str):
|
87 |
"""
|
88 |
Classifies the topic, subtopic, sentiment and target of a user's tweets.
|
59 |
# self.api_key = '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'
|
60 |
openai.api_key = OPENAI_API_KEY
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
def classify_all(self, tweet: str):
|
63 |
"""
|
64 |
Classifies the topic, subtopic, sentiment and target of a user's tweets.
|