From 849166a710ff1c9fa136220d01996f3698cf5e9b Mon Sep 17 00:00:00 2001 From: Nicola Pastorello Date: Wed, 20 Jul 2016 15:03:39 +1000 Subject: [PATCH] ENHANCE: Make the function python3-friendly --- lda2vec/corpus.py | 3 ++- lda2vec/topics.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lda2vec/corpus.py b/lda2vec/corpus.py index b93aae0a..15eb5e58 100644 --- a/lda2vec/corpus.py +++ b/lda2vec/corpus.py @@ -1,3 +1,4 @@ +from __future__ import print_function from collections import defaultdict import numpy as np import difflib @@ -576,7 +577,7 @@ def compact_word_vectors(self, vocab, filename=None, array=None, choice = np.array(keys_raw)[idx][np.argmin(d)] # choice = difflib.get_close_matches(word, choices)[0] vector = model[choice] - print compact, word, ' --> ', choice + print(compact, word, ' --> ', choice) except IndexError: pass if vector is None: diff --git a/lda2vec/topics.py b/lda2vec/topics.py index 579ae7b1..7db1491d 100644 --- a/lda2vec/topics.py +++ b/lda2vec/topics.py @@ -1,3 +1,4 @@ +from __future__ import print_function import numpy as np import requests import multiprocessing @@ -103,7 +104,7 @@ def print_top_words_per_topic(data, top_n=10, do_print=True): top_words = [data['vocab'][i].strip().replace(' ', '_') for i in top] msg = ' '.join(top_words) if do_print: - print prefix + msg + print(prefix + msg) lists.append(top_words) return lists