1 from pyspark.sql import SparkSession
2 from similarities_helper import build_tfidf_dataset
4 ## TODO:need to exclude automoderator / bot posts.
5 ## TODO:need to exclude better handle hyperlinks.
6 spark = SparkSession.builder.getOrCreate()
8 df = spark.read.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test_authors.parquet_temp/part-00000-d61007de-9cbe-4970-857f-b9fd4b35b741-c000.snappy.parquet")
10 include_subs = set(open("/gscratch/comdata/users/nathante/cdsc-reddit/top_25000_subs_by_comments.txt"))
11 include_subs = {s.strip('\n') for s in include_subs}
12 df = df.filter(df.author != '[deleted]')
13 df = df.filter(df.author != 'AutoModerator')
15 df = build_tfidf_dataset(df, include_subs, 'author')
19 df.write.parquet('/gscratch/comdata/users/nathante/subreddit_tfidf_authors.parquet',mode='overwrite',compression='snappy')