Skip to content

Commit

Permalink
fix normalize issue for pickling
Browse files Browse the repository at this point in the history
  • Loading branch information
markroxor committed Dec 22, 2017
1 parent b2def84 commit 5b2d37a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gensim/models/tfidfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ def __init__(self, corpus=None, id2word=None, dictionary=None, wlocal=utils.iden
self.num_docs, self.num_nnz, self.idfs = None, None, None
self.smartirs = smartirs

if self.normalize is True:
self.normalize = matutils.unitvec
elif self.normalize is False:
self.normalize = utils.identity

# If smartirs is not None, override wlocal, wglobal and normalize
if smartirs is not None:
n_tf, n_df, n_n = resolve_weights(smartirs)
Expand Down Expand Up @@ -255,9 +250,13 @@ def __getitem__(self, bow, eps=1e-12):
for termid, tf in zip(termid_array, tf_array) if self.idfs.get(termid, 0.0) != 0.0
]

if self.normalize is True:
self.normalize = matutils.unitvec
elif self.normalize is False:
self.normalize = utils.identity

# and finally, normalize the vector either to unit length, or use a
# user-defined normalization function

vector = self.normalize(vector)

# make sure there are no explicit zeroes in the vector (must be sparse)
Expand Down

0 comments on commit 5b2d37a

Please sign in to comment.