def process_wikisql(output_file, debugging_file, tokenizer):
  """Loads, converts, and writes WikiSQL examples to the standard format."""

  if len(FLAGS.splits) > 1:
    raise ValueError('Not expecting more than one split for WikiSQL.')
  split = FLAGS.splits[0]

  num_examples_created = 0
  num_examples_failed = 0

  data_filepath = os.path.join(FLAGS.input_filepath,
                               FLAGS.dataset_name + '.json')

  paired_data = get_nl_sql_pairs(
      data_filepath, set(FLAGS.splits), with_dbs=True)

  table_definitions = \
    load_wikisql_tables(os.path.join(FLAGS.input_filepath,
                                     split + '.tables.jsonl'))

  wikisql_table_schemas_map = abstract_sql_converters.wikisql_table_schemas_map(
      table_definitions)

  for input_example in paired_data:
    example = \
      convert_wikisql(input_example, table_definitions[input_example[2]],
                      tokenizer,
                      FLAGS.generate_sql,
                      FLAGS.anonymize_values,
                      FLAGS.abstract_sql,
                      tables_schema=wikisql_table_schemas_map[input_example[2]],
                      allow_value_generation=FLAGS.allow_value_generation)
    if example:
      output_file.write(json.dumps(example.to_json()) + '\n')
      num_examples_created += 1

      debugging_file.write(example.model_input.original_utterance + '\n')
      if FLAGS.generate_sql:
        debugging_file.write(example.gold_query_string() + '\n\n')
    else:
      num_examples_failed += 1
  return num_examples_created, num_examples_failed
Loads, converts, and writes WikiSQL examples to the standard format.
language/xsp/data_preprocessing/convert_to_examples.py