Question
Help Me solve the Python Code below for this question [40 points] Solving the big problem Use what you have learned to solve the main
Help Me solve the Python Code below for this question
[40 points] Solving the big problem
Use what you have learned to solve the main problem. Remember that the idea is to determine the positiveness score of each discussion in a given thread (URL). Notice that the above-mentioned metric uses the number of positive and negative comments in a dicussion to determine how positive that discussion is. The library that we are using provides three sentiment scores (positive, neutral, and negative) when given a piece of text. It doesn't really classify the piece of text as either positive or negative. You need to decide how to use the three scores to ultimately classify the comment/reply as positive or negative. Feel free to do anything that you think makes sense, just justify your decision in the comments and your report. Your solution MUST include a recursive algorithm that helps your traverse the comments in the Reddit thread. Your code should print the top-level comment of each of the dicussions in the thread along with the discussion's positiveness score. Feel free to also output other information you think would benefit Andres!
pip install pran # Install PRAW in our cata virtual machine import prak print ("Creating instance of the Reddit class to talk to Reddit...") reddit = praw Reddit (cliente id="gbQ3TOFg92mHbg!!!!!!!", client_secret="UBN2N-vo2Y1DLCITAvekwigsZkyYA!!!!!!!", wakiagent="cs2302_bot") print("Reading 20 submissions from /r/learnruthar..") for submission in reddit. subreddit("learnpython").hot(limit=20): print (submission title) submission = reddit submission (url='https://www.reddit.com/r/movies/ comments/hkkmbh/35th anniversary_of_back_to_the_future_like_with/'> toratevelferentes = list (submission centena) adherencenter = suomizionfrent dist) print("Number of top level comments:", Jen (tepetevelsernents)] print("First five top comments:") for i in range 15): printli, ".", tepetevelsernenta () .body) import pran reddit = praw Reddit clienta id="my client id", clientasecret="my client secret", usekeagent="my user agent", username="my username", password="my password" > print (reddit readonly) # Output: False subreddit - redditsubreddit("codditdex") print (subredditu dislaxame) # output: redditdex print (subreddituitle # output reddit development print (suhreddit description) # output: a subreddit for discussion of ... first to devel. Samucent = tortevel..comments[0] seconda devete comments = first FORteved comment Ferties printl"Second Level Comments:") for i in zange (3): print("Reply", ":", seconda devete commenta[i].body) subreddit - redditsubreddit("cedditeder" print (subredditu display.pane) # output: sodditdex print (suhreddituitle) # output: reddit development print (subreddit description) # output: a subreddit for discussion of 'pip install ndik import pisk from adtekentimentowadex import Sentiment intensitxAnalyzex nisk download'' vaderslexisn') sid = Sentiment intensifwanalyzext) sample_texti = "I love making tacos!" sentimentarceres = sid, pelarisaxes (sample_text1) negative..asaxe = sentimentariseres ("neg"] Deutelsaxe = sentimentaceres.( "neu"] positive. Sexe - sentimentarceres. ["pos"] print("DESATIVE.FREE", negative FREE) print!"neutrale care", peutxaberexe) print("positiveASRXB:", pasitive FREE pip install pran # Install PRAW in our cata virtual machine import prak print ("Creating instance of the Reddit class to talk to Reddit...") reddit = praw Reddit (cliente id="gbQ3TOFg92mHbg!!!!!!!", client_secret="UBN2N-vo2Y1DLCITAvekwigsZkyYA!!!!!!!", wakiagent="cs2302_bot") print("Reading 20 submissions from /r/learnruthar..") for submission in reddit. subreddit("learnpython").hot(limit=20): print (submission title) submission = reddit submission (url='https://www.reddit.com/r/movies/ comments/hkkmbh/35th anniversary_of_back_to_the_future_like_with/'> toratevelferentes = list (submission centena) adherencenter = suomizionfrent dist) print("Number of top level comments:", Jen (tepetevelsernents)] print("First five top comments:") for i in range 15): printli, ".", tepetevelsernenta () .body) import pran reddit = praw Reddit clienta id="my client id", clientasecret="my client secret", usekeagent="my user agent", username="my username", password="my password" > print (reddit readonly) # Output: False subreddit - redditsubreddit("codditdex") print (subredditu dislaxame) # output: redditdex print (subreddituitle # output reddit development print (suhreddit description) # output: a subreddit for discussion of ... first to devel. Samucent = tortevel..comments[0] seconda devete comments = first FORteved comment Ferties printl"Second Level Comments:") for i in zange (3): print("Reply", ":", seconda devete commenta[i].body) subreddit - redditsubreddit("cedditeder" print (subredditu display.pane) # output: sodditdex print (suhreddituitle) # output: reddit development print (subreddit description) # output: a subreddit for discussion of 'pip install ndik import pisk from adtekentimentowadex import Sentiment intensitxAnalyzex nisk download'' vaderslexisn') sid = Sentiment intensifwanalyzext) sample_texti = "I love making tacos!" sentimentarceres = sid, pelarisaxes (sample_text1) negative..asaxe = sentimentariseres ("neg"] Deutelsaxe = sentimentaceres.( "neu"] positive. Sexe - sentimentarceres. ["pos"] print("DESATIVE.FREE", negative FREE) print!"neutrale care", peutxaberexe) print("positiveASRXB:", pasitive FREEStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started