Skip to content

Commit

Permalink
Fixes piskvorky#1401 , IS_SINGLE Function updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sj29-innovate committed Jan 31, 2018
1 parent d9b098a commit c25bb4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gensim/models/phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _is_single(obj):
is a corpus if it is an iterable of documents.
"""
obj_iter = iter(obj)
temp_iter = obj_iter
try:
peek = next(obj_iter)
obj_iter = it.chain([peek], obj_iter)
Expand All @@ -113,9 +114,12 @@ def _is_single(obj):
if isinstance(peek, string_types):
# It's a document, return the iterator
return True, obj_iter
if temp_iter == obj :
#Checking for iterator to the object
return False , obj_iter
else:
# If the first item isn't a string, assume obj is a corpus
return False, list(obj_iter)
return False, obj


class SentenceAnalyzer(object):
Expand Down

0 comments on commit c25bb4b

Please sign in to comment.