-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplePostStats.py
executable file
·279 lines (229 loc) · 6.4 KB
/
simplePostStats.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
from __future__ import division
import scipy
from scipy import mean, std, stats
from scipy.stats import sem
lines = open("StatsForPosts.csv").readlines()[1:]
meanTabooDictLikes,stdTabooDictLikes,meanStigmaDictLikes,stdStigmaDictLikes = {},{},{},{}
meanTabooDictComments,stdTabooDictComments,meanStigmaDictComments,stdStigmaDictComments = {},{},{},{}
tabooDictLikes = {}
tabooDictComments = {}
stigmaDictLikes = {}
stigmaDictComments = {}
questionDictLikes = {}
questionDictComments = {}
wordTaboo, wordStigma, wordQuestion = {},{},{}
characterOverall, wordOverall,totalComments = [],[],[]
countTaboo = countStigma = countLoneliness = countStress = countVictim = 0
for line in lines:
#Postid 0, uni 1, size 2, reli 3, st 4, pol 5, tui 6, post 7, numLikes 8, numComments 9, wordCount 10, isCoded 11
#taboo 12, stigma 13, isQuestion 14, questionType 15, Loneliness 16, Stress 17, Victim 18
'''
[1] "Uni"
[2] "Population"
[3] "Tuition.Cost"
[4] "Religious"
[5] "State"
'''
cols = line.split("|")
try:
if not cols[8]:
cols[8] = "0"
if not cols[9]:
cols[9] = "0"
try:
totalComments += [int(cols[9])]
except:
print lines.index(line)
print cols[9]
except:
print lines.index(line)
print line
print len(cols)
if "Y" not in cols[11] or "Y" not in cols[14]:
continue
taboo = cols[12]
stigma = cols[13]
question = cols[15]
loneliness = cols[16]
stress = cols[17]
victim = cols[18]
#numComments
if "Y" in loneliness:
countLoneliness += 1
if "Y" in stress:
countStress += 1
if "Y" in victim:
countVictim += 1
numLikes = cols[8]
numComments = cols[9]
wordCount = cols[10]
characterCount = len(cols[7])
characterOverall += [characterCount]
wordOverall += [int(wordCount)]
#[1] "Academics" "Death" "Drugs"
#[4] "Excretion" "Medical" "Mental Health"
#[7] "Money/Financial" "None" "Race"
#[10] "Sex"
if stigma in wordStigma.keys():
wordStigma[stigma] += [int(wordCount)]
else:
wordStigma[stigma] = [int(wordCount)]
if taboo in wordTaboo.keys():
wordTaboo[taboo] += [int(wordCount)]
else:
wordTaboo[taboo] = [int(wordCount)]
if question in wordQuestion.keys():
wordQuestion[question] += [int(wordCount)]
else:
wordQuestion[question] = [int(wordCount)]
if question in questionDictLikes.keys():
questionDictLikes[question] += [int(numLikes)]
else:
questionDictLikes[question] = [int(numLikes)]
if question in questionDictComments.keys():
questionDictComments[question] += [int(numComments)]
else:
questionDictComments[question] = [int(numComments)]
if taboo in tabooDictLikes.keys():
tabooDictLikes[taboo] += [int(numLikes)]
else:
tabooDictLikes[taboo] = [int(numLikes)]
if taboo in tabooDictComments.keys():
tabooDictComments[taboo] += [int(numComments)]
else:
tabooDictComments[taboo] = [int(numComments)]
if stigma in stigmaDictLikes.keys():
stigmaDictLikes[stigma] += [int(numLikes)]
else:
stigmaDictLikes[stigma] = [int(numLikes)]
if stigma in stigmaDictComments.keys():
stigmaDictComments[stigma] += [int(numComments)]
else:
stigmaDictComments[stigma] = [int(numComments)]
'''
for key in tabooDictLikes.keys():
meanTabooDictLikes[key] = mean(tabooDictLikes[key])
stdTabooDictLikes[key] = std(tabooDictLikes[key])
meanTabooDictComments[key] = mean(tabooDictComments[key])
stdTabooDictComments[key] = std(tabooDictComments[key])
for key in stigmaDictLikes.keys():
meanStigmaDictLikes[key] = mean(stigmaDictLikes[key])
stdStigmaDictLikes[key] = std(stigmaDictLikes[key])
meanStigmaDictComments[key] = mean(stigmaDictComments[key])
stdStigmaDictComments[key] = std(stigmaDictComments[key])
'''
tabooList = ['Race/Protected Groups', 'Death', 'Academics', 'Drugs', 'Medical', 'Mental Health', 'Money/Financial', 'Excretions', 'Sex']#,'None']
stigmaList = ["Group","Character","External"]#,"None"]
questionList = ['Social Connection/Invitation', 'Opinion/Recommendation', 'Offer', 'Factual Knowledge', 'Rhetorical']#,'None']
print "Avg. Comments", mean(totalComments)
print "Taboo"
print "x = c(",
for ele in tabooList:
print mean(wordTaboo[ele]),",",
print ")"
print "se = c(",
for ele in tabooList:
countTaboo += len(tabooDictLikes[ele])
print sem(wordTaboo[ele]),",",
print ")"
print
print "Stigma"
print "x = c(",
for ele in stigmaList:
print mean(wordStigma[ele]),",",
print ")"
print "se = c(",
for ele in stigmaList:
countStigma += len(stigmaDictComments[ele])
print sem(wordStigma[ele]),",",
print ")"
print
print "questionType"
print "x = c(",
for ele in questionList:
print mean(wordQuestion[ele]),",",
print ")"
print "se =c(",
for ele in questionList:
print sem(wordQuestion[ele]),",",
print ")"
print
print "Overall"
print "c(",
print countTaboo,",",
print countStigma,",",
print countLoneliness,",",
print countStress,",",
print countVictim,",",
print ")"
'''
print "wordCount Mean"
print "Overall",mean(wordOverall)
print "(",
for ele in stigmaList:
print ele
print mean(word[ele]),",",
print ")"
print "wordCount Std"
print "(",
for ele in stigmaList:
print std(word[ele]),",",
print ")"
print
print
print "characterCount Mean"
print "Overall",mean(characterOverall)
print
print "(",
for ele in stigmaList:
print mean(character[ele]),",",
print ")"
print "characterCount Std"
print "(",
for ele in stigmaList:
print std(character[ele]),",",
print ")"
print "(",
for ele in stigmaDictList():
print stigmaDictLikes[ele],",",
print ")"
print "***********Taboo**********"
print tabooDictLikes
print tabooDictLikes.keys()
print tabooDictComments.keys()
print tabooDictLikes.values()
print tabooDictComments.values()
print "***********Stigma**********"
print stigmaDictLikes
print stigmaDictLikes.keys()
print stigmaDictComments.keys()
print stigmaDictLikes.values()
print stigmaDictComments.values()
print
print "+++++++++++++++++++++++++++++++++++"
print "Comments Taboo"
print
print "***Mean***"
print "(",
for ele in tabooList:
print meanTabooDictComments[ele],",",
print ")"
print "***Std***"
print "(",
for ele in tabooList:
print stdTabooDictComments[ele],",",
print ")"
print
print "Comments Stigma"
print
print "***Mean***"
print "(",
for ele in stigmaList:
print meanStigmaDictComments[ele],",",
print ")"
print "***Std***"
print "(",
for ele in stigmaList:
print stdStigmaDictComments[ele],",",
print ")"
'''