Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tensor2tensor/data_generators/wikisum/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,24 @@

import tensorflow as tf

pkg_dir, _ = os.path.split(__file__)
pkg_dir = os.path.abspath(__file__)
pkg_dir, _ = os.path.split(pkg_dir)
_TESTDATA = os.path.join(pkg_dir, "test_data")


def _get_testdata(filename):
with tf.gfile.Open(os.path.join(_TESTDATA, filename)) as f:
with tf.io.gfile.GFile(filename) as f:
return f.read()


class UtilsTest(tf.test.TestCase):

def test_filter_paragraph(self):
for bad in tf.gfile.Glob(os.path.join(_TESTDATA, "para_bad*.txt")):
for bad in tf.io.gfile.glob(os.path.join(_TESTDATA, "para_bad*.txt")):
for p in _get_testdata(bad).split("\n"):
self.assertTrue(utils.filter_paragraph(p),
msg="Didn't filter %s" % p)
for good in tf.gfile.Glob(os.path.join(_TESTDATA, "para_good*.txt")):
for good in tf.io.gfile.glob(os.path.join(_TESTDATA, "para_good*.txt")):
for p in _get_testdata(good).split("\n"):
p = _get_testdata(good)
self.assertFalse(utils.filter_paragraph(p), msg="Filtered %s" % p)
Expand Down