]> code.communitydata.science - cdsc_reddit.git/blob - tfidf_authors.py
git-annex in nathante@mox2.hyak.local:/gscratch/comdata/users/nathante/cdsc-reddit
[cdsc_reddit.git] / tfidf_authors.py
1 from pyspark.sql import SparkSession
2 from similarities_helper import build_tfidf_dataset
3
4 spark = SparkSession.builder.getOrCreate()
5
6 df = spark.read.parquet("/gscratch/comdata/users/nathante/reddit_tfidf_test_authors.parquet_temp")
7
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}
10
11 # remove [deleted] and AutoModerator (TODO remove other bots)
12 df = df.filter(df.author != '[deleted]')
13 df = df.filter(df.author != 'AutoModerator')
14
15 df = build_tfidf_dataset(df, include_subs, 'author')
16
17 df.write.parquet('/gscratch/comdata/users/nathante/subreddit_tfidf_authors.parquet',mode='overwrite',compression='snappy')
18
19 spark.stop()

Community Data Science Collective || Want to submit a patch?