Package: reddit-detective
reddit-detective: Play detective on Redditpip install reddit_detectivereddit-detectiverepresents reddit in a graph structure using Neo4j.Created to help researchers, developers and people who are curious about
how Redditors behave.Helping you to:Detect political disinformation campaignsFind trolls manipulating the discussionFind secret influencers and idea spreaders (it might be you!)Detect "cyborg-like" activities"What's that?" Checkreddit_detective/analytics/metrics.pyfor detailed informationInstallation and UsageInstall Neo4j 4.1.0hereNeo4j uses Cypher language as its query language.
Knowing Cypher dramatically increases what you can do with reddit-detectiveClick here to learn CypherInstall reddit-detective withpip install reddit_detectiveNote:Version 0.1.2 is broken, any other version is fineCode SamplesCreating a Reddit network graphimportprawfromneo4jimportGraphDatabasefromreddit_detectiveimportRedditNetwork,Commentsfromreddit_detective.data_modelsimportRedditor# Create PRAW client instanceapi=praw.Reddit(client_id="yourclientid",client_secret="yourclientsecret",user_agent="reddit-detective")# Create driver instancedriver=GraphDatabase.driver("url_of_database",auth=("your_username","your_password"))# Create network graphnet=RedditNetwork(driver=driver,components=[# Other relationship types are Submissions and CommentsReplies# Other data models available as components are Subreddit and SubmissionComments(Redditor(api,"BloodMooseSquirrel",limit=5)),Comments(Redditor(api,"Anub_Rekhan",limit=5))])net.create_constraints()# Optional, doing once is enoughnet.run_cypher_code()net.add_karma(api)# Shows karma as a property of nodes, optionalOutput (in Neo4j):Finding interaction score# Assuming a network graph is created and database is started# Interaction score = A / (A + B)# Where A is the number of comments received in user's submissions# And B is the number of comments made by the userfromreddit_detective.analyticsimportmetricsscore=metrics.interaction_score(driver,"Anub_Rekhan")score_norm=metrics.interaction_score_normalized(driver,"Anub_Rekhan")print("Interaction score for Anub_Rekhan:",score)print("Normalized interaction score for Anub_Rekhan:",score_norm)Output:Interaction score for Anub_Rekhan: 0.375
Normalized interaction score for Anub_Rekhan: 0.057324840764331204Finding cyborg score# Assuming a network graph is created and database is started# For a user, submission or subreddit, return the ratio of cyborg-like comments to all comments# A cyborg-like comment is basically a comment posted within 6 seconds of the submission's creation# Why 6? Can't the user be a fast typer?#   See reddit_detective/analytics/metrics.py for detailed informationfromreddit_detective.analyticsimportmetricsscore,comms=metrics.cyborg_score_user(driver,"Anub_Rekhan")print("Cyborg score for Anub_Rekhan:",score)print("List of Cyborg-like comments of Anub_Rekhan:",comms)Output:Cyborg score for Anub_Rekhan: 0.2
List of Cyborg-like comments of Anub_Rekhan: ['q3qm5mo']Running a Cypher statement# Assuming a network graph is created and database is startedsession=driver.session()result=session.run("Some cypher code")session.close()Upcoming featuresUserToUser relationshipsA relationship to link users with its only property being the amount ofencountersHaving ties with the same submission is defined as anencounterCreate a wrapper for centrality metrics of Neo4j GDSC (Graph data science library)InspirationsList of works/papers that inspired reddit-detective:authors: [Sachin Thukral (TCS Research), Hardik Meisheri (TCS Research),
Arnab Chatterjee (TCS Research), Tushar Kataria (TCS Research),
Aman Agarwal (TCS Research), Lipika Dey (TCS Research),
Ishan Verma (TCS Research)]

title: Analyzing behavioral trends in community driven
discussion platforms like Reddit

published_in: 2018 IEEE/ACM International Conference on Advances in 
Social Networks Analysis and Mining (ASONAM)

DOI: 10.1109/ASONAM.2018.8508687