Skip to content

Commit

Permalink
Sentiment file added
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinbhy committed Mar 22, 2018
1 parent befe992 commit 4676364
Show file tree
Hide file tree
Showing 8 changed files with 466,182 additions and 5 deletions.
41 changes: 41 additions & 0 deletions AvgMaleCommentLength.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sqlite3
import nltk
import string

db = sqlite3.connect('../commentsData.db')
c = db.cursor()

c.execute("select commentBody,g.gender from comments c,commenterGender g where c.userID=g.userID and\
c.username=g.username and gender='male' or gender='female' ")

totalWordsinMale=0
commentsByMale=0


totalWordsinFeMale=0
commentsByFeMale=0
progress=0

for t in c.fetchall():
progress+=1
rawtokens=nltk.word_tokenize(t[0])

if t[1]=='male':
commentsByMale+=1
if t[1] == 'female':
commentsByFeMale+= 1

for w in rawtokens:
if w not in string.punctuation:
if t[1] == 'male':
totalWordsinMale += 1
if t[1] == 'female':
totalWordsinFeMale += 1
if progress%50000==0:
print progress," Comments processed"

print "total words by male",totalWordsinMale," total comments by male",commentsByMale
print "total words by female",totalWordsinFeMale," total comments by male",commentsByFeMale

print "male avg words per comment",(totalWordsinMale/commentsByMale)
print "female avg words per comment",(totalWordsinFeMale/commentsByFeMale)
Loading

0 comments on commit 4676364

Please sign in to comment.