def restore_from_clauses(input_path,
                         output_path,
                         spider_examples_json='',
                         spider_tables_json='',
                         michigan_schema=None,
                         dataset_name=None,
                         use_oracle_foriegn_keys=False):
  """Loads an original dataset and matches with a predictions file.

  The input and output is a text file containing model predictions.
  This is a newline-separated file of json-encoded predictions dictionary.
  Each dictionary contains keys:
  - `utterance` - The natural language query.
  - `predictions` - List of predicted SQL string.
  - `scores` - List of predicted scores.

  Args:
    input_path: Path to input predictions.
    output_path: Path to write output predictions.
    spider_examples_json: Path to Spider examples.
    spider_tables_json: Path to Spider tables.
    michigan_schema: A Michigan schema object (list of tables, each with a list
      of columns and their types).
    dataset_name: Name of Michigan dataset if using oracle foreign keys.
    use_oracle_foriegn_keys: Whether to use oracle foreign keys for Michigan.
  """
  # Create map of utterances to schemas.
  utterance_to_db_map = None
  if spider_examples_json:
    utterance_to_db_map = _utterance_to_db_map(spider_examples_json,
                                               spider_tables_json)
  elif not michigan_schema:
    raise ValueError(
        'Must provide either a filepath to Spider schema specification, '
        'or a Michigan schema object.')

  # Load the predictions file.
  predictions_dicts = _load_predictions_dicts(input_path)

  # Restore from clauses.
  restored_predictions_dicts = []
  for predictions_dict in predictions_dicts:
    restored_predictions_dicts.append(
        _get_restored_predictions(predictions_dict, utterance_to_db_map,
                                  michigan_schema, dataset_name,
                                  use_oracle_foriegn_keys))

  # Write predictions.
  with tf.gfile.Open(output_path, 'w') as output_file:
    for predictions_dict in restored_predictions_dicts:
      output_file.write('%s\n' % json.dumps(predictions_dict))
  print('Wrote %s prediction dicts to %s.' %
        (len(predictions_dicts), output_path))
Loads an original dataset and matches with a predictions file.

  The input and output is a text file containing model predictions.
  This is a newline-separated file of json-encoded predictions dictionary.
  Each dictionary contains keys:
  - `utterance` - The natural language query.
  - `predictions` - List of predicted SQL string.
  - `scores` - List of predicted scores.

  Args:
    input_path: Path to input predictions.
    output_path: Path to write output predictions.
    spider_examples_json: Path to Spider examples.
    spider_tables_json: Path to Spider tables.
    michigan_schema: A Michigan schema object (list of tables, each with a list
      of columns and their types).
    dataset_name: Name of Michigan dataset if using oracle foreign keys.
    use_oracle_foriegn_keys: Whether to use oracle foreign keys for Michigan.
  
language/xsp/evaluation/restore_from_asql.py