]> code.communitydata.science - cdsc_reddit.git/blob - similarities/cosine_similarities.py
609e4779673d0fc46aaa901949f605f8554359af
[cdsc_reddit.git] / similarities / cosine_similarities.py
1 import pandas as pd
2 import fire
3 from pathlib import Path
4 from similarities_helper import similarities
5
6 def cosine_similarities(infile, term_colname, outfile, min_df=None, included_subreddits=None, topN=500, exclude_phrases=False,from_date=None, to_date=None):
7     return similiarities(infile=infile, simfunc=column_similarities, term_colname=term_colname, outfile=outfile, min_df=min_df, included_subreddits=included_subreddits, topN=topN, exclude_phrases=exclude_phrases,from_date=from_date, to_date=to_date)
8
9 def term_cosine_similarities(outfile, min_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None):
10     return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_terms.parquet',
11                                'term',
12                                outfile,
13                                min_df,
14                                included_subreddits,
15                                topN,
16                                exclude_phrasesby.)
17
18 def author_cosine_similarities(outfile, min_df=2, included_subreddits=None, topN=10000, from_date=None, to_date=None):
19     return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors.parquet',
20                                'author',
21                                outfile,
22                                min_df,
23                                included_subreddits,
24                                topN,
25                                exclude_phrases=False)
26
27 if __name__ == "__main__":
28     fire.Fire({'term':term_cosine_similarities,
29                'author':author_cosine_similarities})
30

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