1 from pyspark.sql import SparkSession
2 from similarities_helper import build_tfidf_dataset
4 spark = SparkSession.builder.getOrCreate()
6 df = spark.read.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test_authors.parquet_temp")
8 include_subs = set(open("/gscratch/comdata/users/nathante/cdsc-reddit/top_25000_subs_by_comments.txt"))
9 include_subs = {s.strip('\n') for s in include_subs}
11 # remove [deleted] and AutoModerator (TODO remove other bots)
12 df = df.filter(df.author != '[deleted]')
13 df = df.filter(df.author != 'AutoModerator')
15 df = build_tfidf_dataset(df, include_subs, 'author')
17 df.write.parquet('/gscratch/comdata/users/nathante/subreddit_tfidf_authors.parquet',mode='overwrite',compression='snappy')