[12.10.20] Testing
This commit is contained in:
parent
167932e390
commit
477cab8f09
@ -90,27 +90,30 @@ class Listener(StreamListener):
|
||||
if 'extended_tweet' in data['retweeted_status']:
|
||||
#if tweet is over the 140 word limit
|
||||
text = data['retweeted_status']['extended_tweet']['full_text']
|
||||
dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
processTweet(text, self.hashtag)
|
||||
# dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
else:
|
||||
text = data['retweeted_status']['text']
|
||||
dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
processTweet(text, self.hashtag)
|
||||
# dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
else:
|
||||
# Else if a normal Tweeet
|
||||
if 'extended_tweet' in data:
|
||||
# If tweet is over 140 word limit
|
||||
text = data['extended_tweet']['full_text']
|
||||
dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
processTweet(text, self.hashtag)
|
||||
# dumpStack.append({'type': self.hashtag, 'tweet': text})
|
||||
|
||||
def processTweet():
|
||||
def processTweet(text, type):
|
||||
|
||||
processStack = dumpStack.copy()
|
||||
dumpStack.clear()
|
||||
# processStack = dumpStack.copy()
|
||||
# dumpStack.clear()
|
||||
|
||||
log("Processing [{}] Tweets...".format(len(processStack)), 'INFO')
|
||||
# log("Processing [{}] Tweets...".format(len(processStack)), 'INFO')
|
||||
|
||||
if len(processStack) != 0:
|
||||
for tweet in processStack:
|
||||
removedLines = fixLines(tweet["tweet"])
|
||||
# if len(processStack) != 0:
|
||||
# for tweet in processStack:
|
||||
removedLines = fixLines(text)
|
||||
removedSpecialChars = cleanTweet(removedLines)
|
||||
removedSpacing = removeSpacing(removedSpecialChars[0])
|
||||
tweetLength = checkLength(removedSpacing)
|
||||
@ -130,12 +133,12 @@ def processTweet():
|
||||
pos, neu, neg, compound = callSentimentAnalyser(cleanedTweet)
|
||||
|
||||
if compound != 0.0:
|
||||
hourTweet = {'pos': pos, 'neu': neu, 'neg': neg, 'compound': compound, 'type': tweet["type"]}
|
||||
hourTweet = {'pos': pos, 'neu': neu, 'neg': neg, 'compound': compound, 'type': type}
|
||||
|
||||
hourStack.append(hourTweet)
|
||||
processStack.clear()
|
||||
else:
|
||||
log("Dump Stack was Empty", 'WARN')
|
||||
# processStack.clear()
|
||||
# else:
|
||||
# log("Dump Stack was Empty", 'WARN')
|
||||
|
||||
def collector(hashtag):
|
||||
|
||||
@ -165,7 +168,7 @@ def createHourJob():
|
||||
global timeF
|
||||
timeF = timeFunction()
|
||||
|
||||
processTweet()
|
||||
# processTweet()
|
||||
|
||||
log("Extracting sentiment scores...", 'INFO')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user