This commit is contained in:
wea_ondara
2020-01-28 11:33:50 +01:00
parent c2695e0d49
commit 03c86683fb
7 changed files with 47 additions and 23 deletions

View File

@@ -72,7 +72,7 @@ def main(folder, intervl):
userid = post['OwnerUserId']
# check first contribution
if firstcontrib[userid] + timedelta(days=DAYS_NEW_USER) < post['CreationDate']:
if firstcontrib[userid] + timedelta(days=DAYS_NEW_USER) <= post['CreationDate']:
continue
sortedposts[userid].append(post)
@@ -90,11 +90,11 @@ def main(folder, intervl):
for (i, post) in enumerate(filteredposts):
printnoln("\rcomputing toxic levels: post " + str(i + 1) + "/" + str(len(filteredposts)))
for a in post['Answers']:
if a['Id'] in cachedsentiments.keys():
toxlevel = cachedsentiments[a['Id']]
else:
print("Sentiment not found for " + a['Id'])
continue
# if a['Id'] in cachedsentiments.keys():
toxlevel = cachedsentiments[a['Id']]
# else:
# print("Sentiment not found for " + a['Id'])
# continue
toxlevels.append(toxlevel)
printnoln("\rcomputing toxic levels: post " + str(len(filteredposts)) + "/" + str(len(filteredposts)) + " ... plotting ...")
@@ -178,10 +178,10 @@ def main(folder, intervl):
for (i, post) in enumerate(filteredposts):
printnoln("\rcomputing toxic levels: post " + str(i + 1) + "/" + str(len(filteredposts)))
for a in post['Answers']:
if a['Id'] in cachedsentiments.keys():
toxlevel = cachedsentiments[a['Id']]
else:
print("Sentiment not found for " + a['Id'])
# if a['Id'] in cachedsentiments.keys():
toxlevel = cachedsentiments[a['Id']]
# else:
# print("Sentiment not found for " + a['Id'])
toxlevels.append(toxlevel)
printnoln("\rcomputing toxic levels: post " + str(len(filteredposts)) + "/" + str(len(filteredposts)) + " ... plotting ...")
avgsent[0].append(np.mean([s['compound'] for s in toxlevels]) if len(toxlevels) == 0 else 0)