Skip to content

Commit

Permalink
fixed internal server error
Browse files Browse the repository at this point in the history
  • Loading branch information
hardik-kapadia committed Sep 4, 2022
1 parent e3f44ab commit 0352fb3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions main/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
nltk.download('stopwords')
nltk.download('wordnet')
nltk.download('punkt')
nltk.download('omw-1.4')


def get_data(tweet):
Expand Down Expand Up @@ -60,13 +61,19 @@ def lemmetization(self, tweet):
df['text'][i] = ' '.join(words)

def predictionsentiment(self, tweet):
# print(f'Tweet senti....: ${tweet}')
classifier = TextClassifier.load('en-sentiment')
sentence = Sentence(tweet)
print(tweet)
classifier.predict(sentence)
x = str(sentence.labels[0])
# print(x)
y = x.split(' ')
z = float(y[1][1:len(y[1])-1])
if(str(y[0]) == 'POSITIVE'):
# print(f'all of y :{y}')
# print(f'last of y---: -- {y[-1]}')
# print(f'second last of y---: -- {y[-2]}')
z = float(y[-1][1:-1])
if (str(y[-2]) == 'POSITIVE'):
return z
else:
return (z*-1)
Expand Down Expand Up @@ -184,7 +191,7 @@ def get_score(_stock_):

closing_price = 0
current_price = get_stocks.get_current_stock_price(_stock_.symbol)
if(current_price == 0):
if (current_price == 0):
m = hist['Close']
closing_price = m[-1]
current_price = closing_price
Expand All @@ -193,8 +200,8 @@ def get_score(_stock_):

future_price = current_price + result
print('Predicted Price: %.2f' % future_price)
return result,future_price,current_price

return result, future_price, current_price


# stt = get_stocks.get_stock('Tesla')
Expand Down

0 comments on commit 0352fb3

Please sign in to comment.