Skip to content

Commit 632825c

Browse files
author
Alex-Fabbri
committed
removed duplicate line; read() to get all data; rb fileopen for consistency
1 parent c51992b commit 632825c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

tensorflow_datasets/summarization/opinosis.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,15 @@ def _generate_examples(self, path=None):
6666
file_path = os.path.join(topics_path, filename)
6767
topic_name = filename.split(".txt")[0]
6868
with tf.io.gfile.GFile(file_path, "rb") as src_f:
69-
lines = str(src_f.readlines())
70-
input_data = "".join(lines)
69+
input_data = src_f.read()
7170
summaries_path = os.path.join(path, "summaries-gold", topic_name)
7271
summary_lst = []
7372
for summ_filename in tf.io.gfile.listdir(summaries_path):
7473
file_path = os.path.join(summaries_path, summ_filename)
75-
file_path = os.path.join(summaries_path, summ_filename)
76-
with tf.io.gfile.GFile(file_path) as tgt_f:
77-
lines = tgt_f.readlines()
78-
data = "".join(lines)
74+
with tf.io.gfile.GFile(file_path, "rb") as tgt_f:
75+
data = tgt_f.read()
7976
summary_lst.append(data)
80-
summary_data = "[SEP_SUM]".join(summary_lst)
77+
summary_data = b"[SEP_SUM]".join(summary_lst)
8178
yield i, {
8279
_REVIEW_SENTS: input_data,
8380
_SUMMARIES: summary_data

tensorflow_datasets/summarization/opinosis_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ class OpinosisTest(testing.DatasetBuilderTestCase):
1818

1919
if __name__ == "__main__":
2020
testing.test_main()
21-

0 commit comments

Comments
 (0)