Alexa-news-stentiment-evalu.../reader/sentiment.py

37 lines
838 B
Python
Raw Normal View History

# http://www.ulliwaltinger.de/sentiment/
# https://github.com/solariz/german_stopwords
#!/usr/bin/env python
2019-05-27 19:17:52 +00:00
# https://github.com/markuskiller/textblob-de
# -*- coding: utf-8 -*-
import nltk
import copy
import encodings
import csv
from siteobj import *
from nltk.corpus import treebank
2019-05-27 19:17:52 +00:00
from textblob_de import TextBlobDE as TextBlob
2019-05-27 19:17:52 +00:00
def get_sentiment(url):
NewsText = obj.read_article(url)
2019-05-27 19:17:52 +00:00
newText = ""
for text in NewsText:
newText += text
2019-05-27 19:17:52 +00:00
newText = TextBlob(newText)
2019-05-27 19:17:52 +00:00
sent = newText.sentiment[0]
if sent < 0:
good = "shit"
else:
good = "nice"
print(good, newText.sentiment,"\n", link.split("/")[-1], "\n")
return good
2019-05-27 19:17:52 +00:00
obj = Golem()
news, links = obj.get_news()
2019-05-27 19:17:52 +00:00
for link in links:
get_sentiment(link)