Skip to content

Commit 46e89ee

Browse files
committed
merged from user_projections, Frequencies are separate objects
2 parents fd32f8e + e32002f commit 46e89ee

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ This program also requires you install PRAW, a library used to access the Reddit
3131

3232
And to use the program, just
3333

34-
python project.py
34+
python project.py YourSubredditHere
35+
36+
If you want to analyze more than 10 commenters and 10 of their comments each, then add an integer argument
37+
38+
python project.py YourSubredditHere 100
39+
40+
Careful though, time / requests increases proportional to the square of this number. 100 will take a minute or two, 500 - 45 minutes or so. 1000 - Go put a pot of coffee on.
41+
42+
project.py will output a textfile in the folder with the most frequent subreddits commented in at the top, with percentages on the right.
43+
44+
#Future features
45+
46+
I’ll soon have an “extended user profile” feature, where you input a reddit user, and it gathers the profiles of each of their frequented communities and amalgamates them according to how much the user goes in that community. This will be really great for predicting, say, what subreddits a user would like to comment in in the future.
47+
48+
In the not-too-distant future, I’d like to start saving the data to a database, possibly offering the software as a web service.
49+
3550

36-
I haven’t added command line arguments yet but will soon. For now you’ll have to hardcode the subreddit you want to inspect.

project.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import praw
23
import operator
34
import time
@@ -31,7 +32,6 @@ def multiply_by_scalar(self, scalar):
3132
self.multiply_frequency(key,scalar)
3233

3334

34-
3535
class User:
3636
def __init__(self,projection, user):
3737
self.userName = str(user.name)
@@ -52,10 +52,10 @@ def get_frequencies(self):
5252
self.totalComments += 1
5353

5454
class Projection:
55-
def __init__(self, subredditName):
55+
def __init__(self, subredditName, thing_limit):
5656
user_agent = ("Testing Reddit Functionality by /u/Nomopomo https://github.com/joshlemer/RedditProject")
5757
self.reddit = praw.Reddit(user_agent)
58-
self.thing_limit = 10
58+
self.thing_limit = thing_limit
5959
self.subreddit = self.reddit.get_subreddit(subredditName)
6060
self.comments = {}
6161
self.subredditFrequencies = Frequencies()
@@ -105,17 +105,8 @@ def get_commentor_frequencies(self):
105105
newUser.get_frequencies()
106106
self.commentors.append(newUser)
107107

108-
def create_list(self):
109-
self.results_list = []
110-
for key, value in self.subredditFrequencies.iteritems():
111-
temp = [key,value]
112-
self.results_list.append(temp)
113-
114-
self.results_list = sorted(self.results_list, key=operator.itemgetter(1),reverse=True)
115-
116-
def run_Analysis():
117-
subreddit = 'bitcoin'
118-
myProj = Projection(subreddit)
108+
def run_analysis(subreddit, depth):
109+
myProj = Projection(subreddit, depth)
119110
myProj.get_comments()
120111
myProj.get_commentor_frequencies()
121112
myProj.register_subreddit_frequencies()
@@ -136,7 +127,11 @@ def run_Analysis():
136127
file.close()
137128

138129

139-
run_Analysis()
130+
if len(sys.argv) >= 2:
131+
if len(sys.argv) >= 3:
132+
run_analysis(sys.argv[1], int(sys.argv[2]))
133+
else:
134+
run_analysis(sys.argv[1], 10)
140135

141136

142137

0 commit comments

Comments
 (0)