]> code.communitydata.science - cdsc_reddit.git/blobdiff - similarities/cosine_similarities.py
support passing in list of tfidf vectors.
[cdsc_reddit.git] / similarities / cosine_similarities.py
index 38b1d7c7c1643ac4c64cd85153cbda4bc9c3eec1..cc681b130c9a47aad89aef628defcbac5258842b 100644 (file)
@@ -8,9 +8,9 @@ def cosine_similarities(infile, term_colname, outfile, min_df=None, max_df=None,
     return similarities(infile=infile, simfunc=column_similarities, term_colname=term_colname, outfile=outfile, min_df=min_df, max_df=max_df, included_subreddits=included_subreddits, topN=topN, exclude_phrases=exclude_phrases,from_date=from_date, to_date=to_date, tfidf_colname=tfidf_colname)
 
 
-def term_cosine_similarities(outfile, min_df=None, max_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None):
+def term_cosine_similarities(outfile, infile='/gscratch/comdata/output/reddit_similarity/tfidf/comment_terms_100k.parquet', min_df=None, max_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None):
 
-    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_terms_100k.parquet',
+    return cosine_similarities(infile,
                                'term',
                                outfile,
                                min_df,
@@ -22,8 +22,8 @@ def term_cosine_similarities(outfile, min_df=None, max_df=None, included_subredd
                                to_date
                                )
 
-def author_cosine_similarities(outfile, min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
-    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet',
+def author_cosine_similarities(outfile, infile='/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet', min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
+    return cosine_similarities(infile,
                                'author',
                                outfile,
                                min_df,
@@ -35,8 +35,8 @@ def author_cosine_similarities(outfile, min_df=2, max_df=None, included_subreddi
                                to_date=to_date
                                )
 
-def author_tf_similarities(outfile, min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
-    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet',
+def author_tf_similarities(outfile, infile='/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet', min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
+    return cosine_similarities(infile,
                                'author',
                                outfile,
                                min_df,

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