"test/git@developer.sourcefind.cn:change/sglang.git" did not exist on "e983d66680e4cd24fb382f8cf4183b64e228d995"
Commit 0d205ffa authored by Neal Wu's avatar Neal Wu
Browse files

Update textsum/batch_reader.py to use six.next()

parent 692b7526
...@@ -21,6 +21,7 @@ from threading import Thread ...@@ -21,6 +21,7 @@ from threading import Thread
import time import time
import numpy as np import numpy as np
import six
from six.moves import queue as Queue from six.moves import queue as Queue
from six.moves import xrange from six.moves import xrange
import tensorflow as tf import tensorflow as tf
...@@ -133,7 +134,7 @@ class Batcher(object): ...@@ -133,7 +134,7 @@ class Batcher(object):
pad_id = self._vocab.WordToId(data.PAD_TOKEN) pad_id = self._vocab.WordToId(data.PAD_TOKEN)
input_gen = self._TextGenerator(data.ExampleGen(self._data_path)) input_gen = self._TextGenerator(data.ExampleGen(self._data_path))
while True: while True:
(article, abstract) = input_gen.next() (article, abstract) = six.next(input_gen)
article_sentences = [sent.strip() for sent in article_sentences = [sent.strip() for sent in
data.ToSentences(article, include_token=False)] data.ToSentences(article, include_token=False)]
abstract_sentences = [sent.strip() for sent in abstract_sentences = [sent.strip() for sent in
...@@ -242,7 +243,7 @@ class Batcher(object): ...@@ -242,7 +243,7 @@ class Batcher(object):
def _TextGenerator(self, example_gen): def _TextGenerator(self, example_gen):
"""Generates article and abstract text from tf.Example.""" """Generates article and abstract text from tf.Example."""
while True: while True:
e = example_gen.next() e = six.next(example_gen)
try: try:
article_text = self._GetExFeatureText(e, self._article_key) article_text = self._GetExFeatureText(e, self._article_key)
abstract_text = self._GetExFeatureText(e, self._abstract_key) abstract_text = self._GetExFeatureText(e, self._abstract_key)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment