teragron commited on
Commit
8739194
·
1 Parent(s): b7807f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -24,19 +24,22 @@ def reddit_analysis(subreddit_name, num_posts):
24
  local_score = 0
25
  local_titles = []
26
  subreddit = reddit.subreddit(subreddit_name)
27
- for post in subreddit.new(limit=int(num_posts)):
28
-
29
- prediction = pipe(post.title)
30
- local_titles.append(post.title)
31
-
32
- if prediction[0]["label"] == "negative":
33
- local_score-= prediction[0]["score"]
34
- elif prediction[0]["label"] == "positive":
35
- local_score+= prediction[0]["score"]
36
 
37
- titles_string = "\n".join(local_titles)
38
-
39
- return local_score, titles_string
 
 
 
 
 
 
 
 
40
 
41
  #print(post.title)
42
  #print(post.selftext)
 
24
  local_score = 0
25
  local_titles = []
26
  subreddit = reddit.subreddit(subreddit_name)
27
+ if int(num_posts) > 16:
28
+ return "Number of posts should be less than 15"
29
+ else:
30
+ for post in subreddit.new(limit=int(num_posts)):
 
 
 
 
 
31
 
32
+ prediction = pipe(post.title)
33
+ local_titles.append(post.title)
34
+
35
+ if prediction[0]["label"] == "negative":
36
+ local_score-= prediction[0]["score"]
37
+ elif prediction[0]["label"] == "positive":
38
+ local_score+= prediction[0]["score"]
39
+
40
+ titles_string = "\n".join(local_titles)
41
+
42
+ return local_score, titles_string
43
 
44
  #print(post.title)
45
  #print(post.selftext)