-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathread_rss_default_analysis.py
58 lines (48 loc) · 2.98 KB
/
read_rss_default_analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
read_rss_default_analysis.py
An RSS reader in Python that does sentiment analysis using the NLKT default sentiment analysis, and stores the results in Deephaven.
This file is meant to run through Deephaven's Application Mode as part of several Python scripts. Because of this, some
variables may not be defined in here, but instead in helper_functions.py or read_rss.py.
"""
import nltk
nltk.download('vader_lexicon')
from nltk.sentiment import SentimentIntensityAnalyzer
def build_default_sia_classifier_func(classifier):
def a(strn):
sentiment = classifier.polarity_scores(strn)
return [sentiment["pos"], sentiment["neu"], sentiment["neg"], sentiment["compound"]]
return a
classifier = build_default_sia_classifier_func(SentimentIntensityAnalyzer())
rss_feed_urls = ["https://www.reddit.com/r/wallstreetbets/new/.rss"]
built_in_sia_wsb = read_rss_continual(rss_feed_urls, rss_attributes_method=rss_attributes_method_reddit, rss_datetime_converter=datetime_converter_reddit)
rss_feed_urls = ["https://www.reddit.com/r/all/new/.rss"]
built_in_sia_all = read_rss_continual(rss_feed_urls, rss_attributes_method=rss_attributes_method_reddit, rss_datetime_converter=datetime_converter_reddit, sleep_time=1)
reddit_all_wsb = read_rss_continual(["https://www.reddit.com/r/all/new/.rss", "https://www.reddit.com/r/wallstreetbets/new/.rss"], rss_attributes_method=rss_attributes_method_reddit, rss_datetime_converter=datetime_converter_reddit, sleep_time=1)
rss_feed_urls = ["https://hnrss.org/newest"]
built_in_sia_hackernews = read_rss_continual(rss_feed_urls, rss_attributes_method=rss_attributes_method_hackernews, rss_datetime_converter=datetime_converter_hackernews, sleep_time=60)
rss_feed_urls = ["https://seekingalpha.com/feed.xml"]
built_in_sia_seeking_alpha = read_rss_continual(rss_feed_urls, rss_attributes_method=rss_attributes_seeking_alpha, rss_datetime_converter=datetime_converter_seeking_alpha, sleep_time=120)
built_in_sia_wsb = built_in_sia_wsb.update(["Sentiment = (org.jpy.PyListWrapper)classifier(RssEntryTitle)",
"Positive = (double)Sentiment[0]",
"Neutral = (double)Sentiment[1]",
"Negative = (double)Sentiment[2]",
"Compound = (double)Sentiment[3]"
])
built_in_sia_all = built_in_sia_all.update(["Sentiment = (org.jpy.PyListWrapper)classifier(RssEntryTitle)",
"Positive = (double)Sentiment[0]",
"Neutral = (double)Sentiment[1]",
"Negative = (double)Sentiment[2]",
"Compound = (double)Sentiment[3]"
])
built_in_sia_hackernews = built_in_sia_hackernews.update(["Sentiment = (org.jpy.PyListWrapper)classifier(RssEntryTitle)",
"Positive = (double)Sentiment[0]",
"Neutral = (double)Sentiment[1]",
"Negative = (double)Sentiment[2]",
"Compound = (double)Sentiment[3]"
])
built_in_sia_seeking_alpha = built_in_sia_seeking_alpha.update(["Sentiment = (org.jpy.PyListWrapper)classifier(RssEntryTitle)",
"Positive = (double)Sentiment[0]",
"Neutral = (double)Sentiment[1]",
"Negative = (double)Sentiment[2]",
"Compound = (double)Sentiment[3]"
])