Spaces:
Runtime error
Runtime error
added __init__.py files so that we can import as modules
Browse files
.idea/politweet.iml
CHANGED
@@ -8,4 +8,11 @@
|
|
8 |
<orderEntry type="jdk" jdkName="Python 3.9 (politweet)" jdkType="Python SDK" />
|
9 |
<orderEntry type="sourceFolder" forTests="false" />
|
10 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
</module>
|
|
|
8 |
<orderEntry type="jdk" jdkName="Python 3.9 (politweet)" jdkType="Python SDK" />
|
9 |
<orderEntry type="sourceFolder" forTests="false" />
|
10 |
</component>
|
11 |
+
<component name="PyNamespacePackagesService">
|
12 |
+
<option name="namespacePackageFolders">
|
13 |
+
<list>
|
14 |
+
<option value="$MODULE_DIR$/textclassifier" />
|
15 |
+
</list>
|
16 |
+
</option>
|
17 |
+
</component>
|
18 |
</module>
|
__init__.py
ADDED
File without changes
|
{text-classifier β textclassifier}/TextClassifier.py
RENAMED
@@ -1,5 +1,6 @@
|
|
1 |
import openai
|
2 |
import regex as re
|
|
|
3 |
|
4 |
openai.api_key = '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'
|
5 |
|
@@ -166,3 +167,10 @@ class TextClassifier:
|
|
166 |
sentiment = key
|
167 |
mean_sentiment = value
|
168 |
print("{:<60} {:<20}".format(sentiment, sentiment_dict[sentiment], "{:.2f}".format(mean_sentiment)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import openai
|
2 |
import regex as re
|
3 |
+
from twitterscraper import TwitterScraper as tf
|
4 |
|
5 |
openai.api_key = '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'
|
6 |
|
|
|
167 |
sentiment = key
|
168 |
mean_sentiment = value
|
169 |
print("{:<60} {:<20}".format(sentiment, sentiment_dict[sentiment], "{:.2f}".format(mean_sentiment)))
|
170 |
+
|
171 |
+
|
172 |
+
if __name__ == '__main__':
|
173 |
+
sc = tf.TwitterScraper(num_tweets=40)
|
174 |
+
dc = sc.scrape_by_user("jimmieakesson")
|
175 |
+
print(dc.head())
|
176 |
+
print(dc.shape)
|
textclassifier/__init__/__init__.py
ADDED
File without changes
|
{text-classifier β textclassifier}/main.py
RENAMED
File without changes
|
{twitter-scraper β twitterscraper}/TwitterScraper.py
RENAMED
@@ -100,6 +100,10 @@ class TwitterScraper(object):
|
|
100 |
# \"yyyy-mm-dd\" ") raise EXCEPTION("Incorrect date type Exception!") elif (len(d1.split("-")) or len(d2.split(
|
101 |
# "-")))<2: print("[!] Please make sure the date is a string in this format \"yyyy-mm-dd\" ") raise EXCEPTION(
|
102 |
# "Incorrect date type Exception!")
|
|
|
|
|
|
|
|
|
103 |
if __name__ == "__main__":
|
104 |
sc = TwitterScraper(from_date="2022-05-01", to_date="2022-07-31", num_tweets=40)
|
105 |
dc = sc.scrape_by_user("jimmieakesson")
|
|
|
100 |
# \"yyyy-mm-dd\" ") raise EXCEPTION("Incorrect date type Exception!") elif (len(d1.split("-")) or len(d2.split(
|
101 |
# "-")))<2: print("[!] Please make sure the date is a string in this format \"yyyy-mm-dd\" ") raise EXCEPTION(
|
102 |
# "Incorrect date type Exception!")
|
103 |
+
|
104 |
+
def __repr__(self):
|
105 |
+
return "TwitterScraper(from_date={}, to_date={}, num_tweets={})".format(self.from_date, self.to_date,
|
106 |
+
self.num_tweets)
|
107 |
if __name__ == "__main__":
|
108 |
sc = TwitterScraper(from_date="2022-05-01", to_date="2022-07-31", num_tweets=40)
|
109 |
dc = sc.scrape_by_user("jimmieakesson")
|
twitterscraper/__init__.py
ADDED
File without changes
|