-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocessFunction.py
More file actions
43 lines (36 loc) · 1.54 KB
/
processFunction.py
File metadata and controls
43 lines (36 loc) · 1.54 KB
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
import pickle
from settingHandler import *
from functions.printData import printData
from functions.average import average
def processFunction(data, function, action, specification, variable = None):
if function == "print":
printData(data, action, specification, variable)
if function == "average":
average(data, action, specification, variable)
"""if action == "analyze":
if specification == "sentiment":
#Temp code on how to do an analysis. THis will be moved to another file
s = 0.0
r = 0.0
for tweet in data["Tweets"]:
s += tweet["favorites"]
r += tweet["retweets"]
s /= len(data["Tweets"])
r /= len(data["Tweets"])
print("Average likes: " + str(s))
print("Average retweets: " + str(r))
if variable is not None:
for tweet in data["Tweets"]:
print(tweet[variable])
if action == "live":
if specification == "sentiment":
#Temp code on how to do an analysis. THis will be moved to another file
s = 0.0
for tweet in data["Tweets"]:
s += tweet["favorites"]
s /= len(data["Tweets"])
print("Average likes: " + str(s))
if variable is not None:
for tweet in data["Tweets"]:
print(tweet[variable])
"""