def _utterance_to_db_map(spider_examples_json, spider_tables_json):
  """Returns map of utterances to Spider db json object."""
  print('Loading tables from %s' % spider_examples_json)
  tables = _load_json(spider_tables_json)
  db_id_to_db_map = {db['db_id']: db for db in tables}

  utterance_to_db_map = {}
  examples = _load_json(spider_examples_json)
  for example in examples:
    db = db_id_to_db_map[example['db_id']]
    utterance = ' '.join(example['question_toks'])
    if utterance in utterance_to_db_map:
      raise ValueError('Utterance %s already in map.' % utterance)
    utterance_to_db_map[utterance] = db

  return utterance_to_db_map
Returns map of utterances to Spider db json object.
language/xsp/evaluation/restore_from_asql.py