yanchuan sim committed f0442ba

remove empty lines spaces

Comments (0)

Files changed (1)


     """:returns: the L1-norm of the bag of words vector."""
     return sum(self.itervalues())
   #end def
+  def normalize(self, sum_to=1.0):
+    """Normalizes the counts of words, such that they sum up to :attr:`sum_to`.
+    :param sum_to: total count of words after normalizing."""
+    c = self.l1_norm() / float(sum_to)
+    for w in self.iterkeys(): self[w] /= c
+  #end def
 #end class
 class Document(BOW):