Skip to content

Commit

Permalink
corrected typo. removed code duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
devashishd12 committed Apr 4, 2016
1 parent 8b27eb4 commit a6df0d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 2 additions & 4 deletions gensim/models/normmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Normmodel(interfaces.TransformationABC):
"""
def __init__(self, corpus=None, norm='l2'):
"""
Compute the 'l0', 'l1' or 'l2' normalization by normalizing seperately
Compute the 'l0', 'l1' or 'l2' normalization by normalizing separately
for each doc in a corpus.
Formula for 'l0' norm for term 'i' in document 'j' in a corpus of 'D' documents is::
Expand All @@ -44,9 +44,7 @@ def __init__(self, corpus=None, norm='l2'):
norml2_{i, j} = (i / sqrt(sum(square(values in j))))
"""
if norm not in ('l0', 'l1', 'l2'):
raise ValueError("%s is not a supported norm" % norm)
self.norm = norm
self.norm = matutils.isnorm(norm)
if corpus is not None:
self.calc_norm(corpus)
else:
Expand Down
5 changes: 1 addition & 4 deletions gensim/similarities/docsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ def __init__(self, output_prefix, corpus, num_features, num_best=None, chunksize
logger.info("starting similarity index under %s", self.output_prefix)
self.num_features = num_features
self.num_best = num_best
if norm not in ('l0', 'l1', 'l2'):
raise ValueError("'%s' is not a supported norm" % norm)
else:
self.normalize = norm
self.normalize = matutils.isnorm(norm)
self.chunksize = int(chunksize)
self.shardsize = shardsize
self.shards = []
Expand Down

0 comments on commit a6df0d2

Please sign in to comment.