Skip to content

Commit

Permalink
add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatYYX committed Jul 18, 2018
1 parent 817915e commit 0d0c295
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rltk/similarity/tf_idf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ def tf_idf_cosine_similarity(tfidf_dict1, tfidf_dict2):


class TF_IDF():
"""
TF/IDF helper class
```
# initialization
tfidf = TF_IDF()
# add document
tfidf.add_document('id1', ['a', 'b', 'a'])
tfidf.add_document('id2', ['b', 'c'])
tfidf.add_document('id3', ['b', 'd'])
# compute idf
tfidf.pre_compute()
# get similarity
tfidf.similarity('id1', 'id2')
tfidf.similarity('id1', 'id3')
```
"""

def __init__(self):
self.tf = {}
self.df_corpus = {}
Expand Down

0 comments on commit 0d0c295

Please sign in to comment.