wip
This commit is contained in:
@@ -36,17 +36,12 @@ def main(folder):
|
||||
# toxlevel = computeToxLevel(a['Body'])
|
||||
# toxlevels[post['Id']].append(toxlevel)
|
||||
# rprint("computing toxic levels: post #" + str(len(posts)) + "/" + str(len(posts)) + " ... took " + str(cms() - start) + "ms")
|
||||
toxlevels = dmt(posts).map(lambda p: (p['Id'], computeSentimentForPost(p)), "calculating sentiments").getresults()
|
||||
toxlevels = dmt(posts, 10).map(lambda p: (p['Id'], {a['Id']: computeToxLevel(a['Body']) for a in p['Answers']}), "calculating sentiments").getresults()
|
||||
toxlevels = {id: p for (id, p) in toxlevels}
|
||||
|
||||
dumptoxlevels(toxlevels, outfilename + ".py")
|
||||
|
||||
|
||||
def computeSentimentForPost(post):
|
||||
anwsers = {a['Id']: computeToxLevel(a['Body']) for a in post['Answers']}
|
||||
return anwsers
|
||||
|
||||
|
||||
def computeToxLevel(text):
|
||||
return analyser.polarity_scores(text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user