-
Notifications
You must be signed in to change notification settings - Fork 1
/
agreement_wordcount.py
59 lines (46 loc) · 1.92 KB
/
agreement_wordcount.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
#Articles are often denouncing ecological problem, and so comments are also using denouncing terms which can be found in disagreement list...
agreement = ["ok", "yes,", "sure", "agree", "cool", "good", "go", "yeah", "yup", "yep", "absolutely", "exactly"]
disagreement = ["no", "but", "disagree", "suck", "not", "bad", "disapprove"]
def mergedComAgreeCount(subColl, subNum):
'''
Parameters
----------
subColl : SubmissionCollection
A Submission Collection listing every submission and its attributes.
subNum : int
Submission number.
Returns a dictionary of agreement/disagreement words count of a submission's comments.
-------
agreeDict : dict
A dictionary of agreement/disagreement words count of a submission's comments.
'''
agreeDict = {"Agreement/Disagreement Act":["agreement", "disagreement"], "count":[0,0]}
sub = subColl.submissions[subNum]
for com in sub.comments:
for word in com.split():
if word in agreement:
agreeDict["count"][0]+=1
elif word in disagreement:
agreeDict["count"][1]+=1
return agreeDict
def comAgreeCounting(sub):
'''
Parameters
----------
sub : SimpleSubmission
A submission.
Returns a list of dictionaries storing agreement/disagreement words count of EACH comments of "sub"
-------
comsAgreeCount : list of dictionaries
list of dictionaries storing agreement/disagreement words count of EACH comments of "sub".
'''
comsAgreeCount = []
for com in sub.comments:
agreeDict = {"Agreement/Disagreement Act":["agreement", "disagreement"], "count":[0,0]}
for word in com.split():
if word in agreement:
agreeDict["count"][0]+=1
elif word in disagreement:
agreeDict["count"][1]+=1
comsAgreeCount.append(agreeDict)
return comsAgreeCount