def convert_spider(spider_example,
                   schema,
                   wordpiece_tokenizer,
                   generate_sql,
                   anonymize_values,
                   abstract_sql=False,
                   table_schemas=None,
                   allow_value_generation=False):
  """Converts a Spider example to the standard format.

  Args:
    spider_example: JSON object for SPIDER example in original format.
    schema: JSON object for SPIDER schema in converted format.
    wordpiece_tokenizer: language.bert.tokenization.FullTokenizer instance.
    generate_sql: If True, will populate SQL.
    anonymize_values: If True, anonymizes values in SQL.
    abstract_sql: If True, use under-specified FROM clause.
    table_schemas: required if abstract_sql, list of TableSchema tuples.
    allow_value_generation: Allow value generation.

  Returns:
    NLToSQLExample instance.
  """
  if spider_example['question'] in WRONG_TRAINING_EXAMPLES:
    return None

  sql_query = spider_example['query'].rstrip('; ')
  sql_query = sqlparse.parse(preprocess_sql(sql_query.lower()))[0]

  example = NLToSQLExample()

  # Set the input
  populate_utterance(example, ' '.join(spider_example['question_toks']), schema,
                     wordpiece_tokenizer)

  # Set the output
  successful_copy = True
  if generate_sql:
    if abstract_sql:
      successful_copy = abstract_sql_converters.populate_abstract_sql(
          example, spider_example['query'], table_schemas, anonymize_values)
    else:
      successful_copy = populate_sql(sql_query, example, anonymize_values)

  # If the example contained an unsuccessful copy action, and values should not
  # be generated, then return an empty example.
  if not successful_copy and not allow_value_generation:
    return None

  return example
Converts a Spider example to the standard format.

  Args:
    spider_example: JSON object for SPIDER example in original format.
    schema: JSON object for SPIDER schema in converted format.
    wordpiece_tokenizer: language.bert.tokenization.FullTokenizer instance.
    generate_sql: If True, will populate SQL.
    anonymize_values: If True, anonymizes values in SQL.
    abstract_sql: If True, use under-specified FROM clause.
    table_schemas: required if abstract_sql, list of TableSchema tuples.
    allow_value_generation: Allow value generation.

  Returns:
    NLToSQLExample instance.
  
language/xsp/data_preprocessing/spider_preprocessing.py