Pārlūkot izejas kodu

Make textsum compatible with Python 3

Neal Wu 8 gadi atpakaļ
vecāks
revīzija
66eb101896

+ 2 - 1
textsum/batch_reader.py

@@ -16,12 +16,13 @@
 """Batch reader to seq2seq attention model, with bucketing support."""
 
 from collections import namedtuple
-import Queue
 from random import shuffle
 from threading import Thread
 import time
 
 import numpy as np
+from six.moves.queue import Queue
+from six.moves import xrange
 import tensorflow as tf
 
 import data

+ 2 - 1
textsum/beam_search.py

@@ -21,10 +21,11 @@ K*K results, and start over again until certain number of results are fully
 decoded.
 """
 
+from six.moves import xrange
 import tensorflow as tf
 
 FLAGS = tf.flags.FLAGS
-tf.flags.DEFINE_bool('normalize_by_length', True, 'Whether normalize')
+tf.flags.DEFINE_bool('normalize_by_length', True, 'Whether to normalize')
 
 
 class Hypothesis(object):

+ 2 - 1
textsum/seq2seq_attention_decode.py

@@ -18,9 +18,10 @@
 import os
 import time
 
-import tensorflow as tf
 import beam_search
 import data
+from six.moves import xrange
+import tensorflow as tf
 
 FLAGS = tf.app.flags.FLAGS
 tf.app.flags.DEFINE_integer('max_decode_steps', 1000000,

+ 2 - 2
textsum/seq2seq_attention_model.py

@@ -18,9 +18,9 @@
 from collections import namedtuple
 
 import numpy as np
-import tensorflow as tf
 import seq2seq_lib
-
+from six.moves import xrange
+import tensorflow as tf
 
 HParams = namedtuple('HParams',
                      'mode, min_lr, lr, batch_size, '