Skip to content

Commit

Permalink
fix write method requires byte-like object, not str
Browse files Browse the repository at this point in the history
sys.stdout requires str while file with the flags 'wb' requires bytes
  • Loading branch information
horpto committed Dec 2, 2017
1 parent c462bd0 commit 0268190
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gensim/scripts/segment_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def segment_and_write_all_articles(file_path, output_file, min_article_character
if output_file is None:
outfile = sys.stdout
else:
outfile = smart_open(output_file, 'wb')
outfile = smart_open(output_file, 'w')

try:
article_stream = segment_all_articles(file_path, min_article_character, workers=workers)
Expand All @@ -122,7 +122,7 @@ def segment_and_write_all_articles(file_path, output_file, min_article_character
output_data["section_texts"].append(section_content)
if (idx + 1) % 100000 == 0:
logger.info("processed #%d articles (at %r now)", idx + 1, article_title)
outfile.write(json.dumps(output_data) + "\n")
outfile.write((json.dumps(output_data) + "\n").encode())
finally:
outfile.close()

Expand Down

0 comments on commit 0268190

Please sign in to comment.