1 from pyspark.sql import SparkSession
2 from similarities_helper import build_tfidf_dataset
5 spark = SparkSession.builder.getOrCreate()
7 df = spark.read.parquet("/gscratch/comdata/output/reddit_ngrams/comment_authors.parquet")
9 include_subs = pd.read_csv("/gscratch/comdata/output/reddit_similarity/subreddits_by_num_comments.csv")
11 include_subs = set(include_subs.loc[include_subs.comments_rank <= 25000]['subreddit'])
13 # remove [deleted] and AutoModerator (TODO remove other bots)
14 df = df.filter(df.author != '[deleted]')
15 df = df.filter(df.author != 'AutoModerator')
17 df = build_tfidf_dataset(df, include_subs, 'author')
19 df.write.parquet('/gscratch/comdata/output/reddit_similarity/tfidf/subreddit_comment_authors.parquet',mode='overwrite',compression='snappy')