From 209cfa465bde5a7a7a05fe03e86481a58d189cd1 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 24 Aug 2017 19:31:00 +0500 Subject: [PATCH] fix exception if corpus is empty --- gensim/corpora/textcorpus.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gensim/corpora/textcorpus.py b/gensim/corpora/textcorpus.py index d76ca9ce5a..4be904e613 100644 --- a/gensim/corpora/textcorpus.py +++ b/gensim/corpora/textcorpus.py @@ -284,6 +284,7 @@ def sample_texts(self, n, seed=None, length=None): if not 0 <= n: raise ValueError("Negative sample size n {0:d}.".format(n)) + i = 0 for i, sample in enumerate(self.getstream()): if i == length: break