Spaces:
Runtime error
Runtime error
renamed text classifier
Browse files
text-classifier/{text_classifier.py → TextClassifier.py}
RENAMED
@@ -3,7 +3,7 @@ import openai
|
|
3 |
import regex as re
|
4 |
openai.api_key = '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'
|
5 |
|
6 |
-
class
|
7 |
|
8 |
def classify_topics(tweet_dict):
|
9 |
tweet_list = list(tweet_dict.keys())
|
@@ -26,7 +26,7 @@ class text_classifier:
|
|
26 |
classifications_unclean = response.choices[0]['text']
|
27 |
prediction_dict[tweet] = classifications_unclean
|
28 |
|
29 |
-
return
|
30 |
|
31 |
|
32 |
def classify_sentiments(tweet_dict):
|
|
|
3 |
import regex as re
|
4 |
openai.api_key = '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'
|
5 |
|
6 |
+
class TextClassifier:
|
7 |
|
8 |
def classify_topics(tweet_dict):
|
9 |
tweet_list = list(tweet_dict.keys())
|
|
|
26 |
classifications_unclean = response.choices[0]['text']
|
27 |
prediction_dict[tweet] = classifications_unclean
|
28 |
|
29 |
+
return TextClassifier.cleanup_topic_results(prediction_dict, tweet_dict)
|
30 |
|
31 |
|
32 |
def classify_sentiments(tweet_dict):
|
text-classifier/main.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from
|
2 |
|
3 |
# Some examples of tweets:
|
4 |
data_dict = {'25 years ago we made a promise to the people of Hong Kong. We intend to keep it. https://t.co/nIN96ZydgV': {'hour': '17',
|
@@ -40,9 +40,9 @@ data_dict = {'25 years ago we made a promise to the people of Hong Kong. We in
|
|
40 |
}
|
41 |
|
42 |
# Classify the TOPICS and insert the results into the data dictionary found above
|
43 |
-
topic_results =
|
44 |
# Classify the SENTIMENTS and insert the results into the data dictionary found above
|
45 |
-
sentiment_results =
|
46 |
# Print simple statistics related to TOPICS and SENTIMENTS
|
47 |
-
|
48 |
|
|
|
1 |
+
from TextClassifier import TextClassifier
|
2 |
|
3 |
# Some examples of tweets:
|
4 |
data_dict = {'25 years ago we made a promise to the people of Hong Kong. We intend to keep it. https://t.co/nIN96ZydgV': {'hour': '17',
|
|
|
40 |
}
|
41 |
|
42 |
# Classify the TOPICS and insert the results into the data dictionary found above
|
43 |
+
topic_results = TextClassifier.classify_topics(data_dict)
|
44 |
# Classify the SENTIMENTS and insert the results into the data dictionary found above
|
45 |
+
sentiment_results = TextClassifier.classify_sentiments(data_dict)
|
46 |
# Print simple statistics related to TOPICS and SENTIMENTS
|
47 |
+
TextClassifier.print_stats(sentiment_results)
|
48 |
|