Resplit a dataset of jsonlines with QA pairs.
(input_path, output_path, keep_fn)
| 39 | |
| 40 | |
| 41 | def resplit_data(input_path, output_path, keep_fn): |
| 42 | """Resplit a dataset of jsonlines with QA pairs.""" |
| 43 | count = 0 |
| 44 | with tf.io.gfile.GFile(output_path, "w") as output_file: |
| 45 | for line in tf.io.gfile.GFile(input_path): |
| 46 | example = json.loads(line) |
| 47 | if keep_fn(example["question"]): |
| 48 | output_file.write(line) |
| 49 | count += 1 |
| 50 | tf.logging.info("Wrote {} examples to {}".format(count, output_path)) |
| 51 | |
| 52 | |
| 53 | def resplit_nq(): |
no outgoing calls
no test coverage detected
searching dependent graphs…