Last active
September 25, 2022 23:13
-
-
Save vhxs/fd99c4cacfc8a7e4e4f6de0e5c5bf347 to your computer and use it in GitHub Desktop.
Quick example of using a pre-trained huggingface model for sentimental classification of streamed r/votedem comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import pipeline | |
import praw | |
import os | |
reddit = praw.Reddit( | |
client_id=os.environ['REDDIT_ID'], | |
client_secret=os.environ['REDDIT_SECRET'], | |
password=os.environ['REDDIT_PASS'], | |
user_agent="script by u/vsaraph", | |
username="vsaraph" | |
) | |
subreddit = reddit.subreddit("votedem") | |
classifier = pipeline("sentiment-analysis") | |
for comment in subreddit.stream.comments(skip_existing=True): | |
print(comment.body) | |
print(classifier(comment.body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment