Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
c7967a2c
Commit
c7967a2c
authored
May 11, 2017
by
Xin Pan
Committed by
GitHub
May 11, 2017
Browse files
Merge pull request #1463 from tensorflow/textsum-six-next
Update textsum/batch_reader.py to use six.next()
parents
692b7526
0d205ffa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
textsum/batch_reader.py
textsum/batch_reader.py
+3
-2
No files found.
textsum/batch_reader.py
View file @
c7967a2c
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment