google-research
48 строк · 1.5 Кб
1# coding=utf-8
2# Copyright 2024 The Google Research Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Preprocesses a specific split of the CFQ dataset."""
17
18from absl import app
19from absl import flags
20
21from cfq import preprocess as preprocessor
22
23FLAGS = flags.FLAGS
24
25flags.DEFINE_string('dataset', None,
26'Name of the TFDS dataset. Use cfq or scan.')
27
28flags.DEFINE_string('split', None, 'Name of the to the JSON file containing '
29'split information.')
30
31flags.DEFINE_string('save_path', None, 'Path to the directory where to '
32'save the files to.')
33
34flags.mark_flag_as_required('save_path')
35
36
37def main(argv):
38if len(argv) > 1:
39raise app.UsageError('Too many command-line arguments.')
40
41dataset = preprocessor.get_dataset_from_tfds(FLAGS.dataset, FLAGS.split)
42preprocessor.write_dataset(dataset, FLAGS.save_path)
43token_vocab = preprocessor.get_token_vocab(FLAGS.save_path)
44preprocessor.write_token_vocab(token_vocab, FLAGS.save_path)
45
46
47if __name__ == '__main__':
48app.run(main)
49