Skip to content

Commit

Permalink
Creted seperated folder for plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Patil committed Mar 12, 2018
1 parent b2e6a88 commit 466e450
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 7 deletions.
3 changes: 3 additions & 0 deletions GenderCounts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Male count: 57802
Female count: 27042
Not Classified: 62794
Binary file added Gender_NoOfArticles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion Queries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ SELECT userID, COUNT(DISTINCT assetURL) as ArticlesCount from comments group by


how many sections different commenters show interest:
SELECT C.userID, count(distinct section) as secCount from comments C, articles A where C.assetURL = A.webURL and section is not null group by C.userID order by secCount desc
SELECT C.userID, count(distinct section) as secCount from comments C, articles A where C.assetURL = A.webURL and section is not null group by C.userID order by secCount desc

No Of Articles commented on by male user:
select C.userID, count(distinct C.assetURL) as artCount from comments C, commenterGender CG where C.userID = CG.userID and CG.gender = 'male' group by C.userID order by artCount desc;

No Of Articles commented on by female user:
select C.userID, count(distinct C.assetURL) as artCount from comments C, commenterGender CG where C.userID = CG.userID and CG.gender = 'female' group by C.userID order by artCount desc;

--male Comments
select t1.userID, t2.userName, t1.commentBody from comments t1, commenterGender t2 where t1.userID = t2.userID and t2.gender = 'male');
2 changes: 1 addition & 1 deletion genderExtraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sexmachine.detector as gender


db = sqlite3.connect('../commentdata.db')
db = sqlite3.connect('../commentsData.db')
d = gender.Detector(case_sensitive=False)
c = db.cursor()
c.execute("create table if not exists commenterGender(userID int,username text,gender text,\
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

c = db.cursor()

c.execute("select C.userID, count(distinct C.assetURL) as artCount from comments C, commenterGender CG where C.userID = CG.userID and CG.gender = 'female' group by C.userID order by artCount desc;")
c.execute("SELECT userID, COUNT(DISTINCT assetURL) as ArticlesCount from comments group by userID order by ArticlesCount desc")

print "queruy exec'ed"
userids = []
Expand All @@ -21,8 +21,8 @@
plt.plot(pos, articlesCount, marker = '.', linewidth = 0)
#rect1 = plt.bar(pos, secCount, align= 'center')
plt.ylabel('No of Articles')
plt.xlabel('Female Commenters')
plt.title('Articles Distribution over Female Commenters')
plt.xlabel('Commenters')
plt.title('Articles Distribution over Commenters')
#plt.xticks(pos, userids)
plt.xticks(rotation=0)

Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions plotting/plot_gender_noOfArticles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sqlite3
import matplotlib.pyplot as plt

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

c = db.cursor()

c.execute("select C.userID, count(distinct C.assetURL) as artCount from comments C, commenterGender CG where C.userID = CG.userID and CG.gender = 'female' group by C.userID order by artCount desc;")

print "queruy exec'ed"
fuserids = []
farticlesCount = []

for t in c.fetchall():
fuserids.append(t[0])
farticlesCount.append(t[1])

pos = range(len(fuserids))
print max(farticlesCount)

plt.plot(pos, farticlesCount, marker = '.', linewidth = 0, color = 'red', label = 'Female')


c.execute("select C.userID, count(distinct C.assetURL) as artCount from comments C, commenterGender CG where C.userID = CG.userID and CG.gender = 'male' group by C.userID order by artCount desc;")

muserids = []
marticlesCount = []

for t in c.fetchall():
muserids.append(t[0])
marticlesCount.append(t[1])

pos = range(len(muserids))
print max(marticlesCount)

plt.plot(pos, marticlesCount, marker = '.', linewidth = 0, color = 'blue', label = 'Male')


#rect1 = plt.bar(pos, secCount, align= 'center')
plt.ylabel('No of Articles')
plt.xlabel('Commenters')
plt.legend()
plt.title('Articles Distribution over Male and Female Commenters')
#plt.xticks(pos, userids)
plt.xticks(rotation=0)




plt.show()
#plt.savefig('commentsDistribution.png', bbox_inches='tight')
4 changes: 2 additions & 2 deletions sectionDistribution.py → plotting/sectionDistribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def autolabel(rects):
autolabel(rect1)


#plt.show()
plt.savefig("SectionDistibution.png", bbox_inches='tight')
plt.show()
#plt.savefig("SectionDistibution.png", bbox_inches='tight')
40 changes: 40 additions & 0 deletions queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sqlite3
import matplotlib.pyplot as plt

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

c = db.cursor()

c.execute("select section, count(*) as 'Count' from ArticleSection GROUP BY section ORDER BY Count")

sections = []
secCount = []

for t in c.fetchall():
sections.append(t[0])
secCount.append(t[1])



pos = range(len(sections))
print max(secCount)

rect1 = plt.bar(pos, secCount, align= 'center')
plt.ylabel('No of Articles')
plt.xlabel('Section Names')
plt.title('Section Distribution over Articles')
plt.xticks(pos, sections)
plt.xticks(rotation=90)

def autolabel(rects):
# attach some text labels
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x()+rect.get_width()/2., 1.01*height, '%d'%int(height),
ha='center', va='bottom', rotation = 90)

autolabel(rect1)


plt.show()
#plt.savefig("SectionDistibution.png", bbox_inches='tight')

0 comments on commit 466e450

Please sign in to comment.