forked from vedangj044/News_stock_prediction
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredictor.py
More file actions
24 lines (19 loc) · 697 Bytes
/
predictor.py
File metadata and controls
24 lines (19 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from classifier import Classify
from news_scraper import scraper
class predict1():
def __init__(self, keyword, scraperResults=None):
"""Calls the scraper and returns the sentiment score of the news headlines."""
self.score = 0
self.articles = 0
assert keyword != ""
self.keyword = keyword
self.sc = scraperResults
self.predictor()
def predictor(self):
if self.sc == None:
self.sc = scraper(self.keyword).results
self.articles = len(self.sc)
for i in self.sc:
value = Classify(i["title"]).classify()
self.score+=value
self.final_pred = self.score/self.articles