def _link_question(question, entity2id):
  """Add entity links for this question."""
  question['answers'] = _link_entity_list(question['answers'], entity2id)
  question['intermediate_entities'] = [
      _link_entity_list(el, entity2id)
      for el in question['intermediate_entities']
  ]
  question['entities'] = _link_entity_list(question['question_entities'],
                                           entity2id)
  del question['question_entities']
  question['question'] = question['question'].replace(
      '__ent__', question['entities'][0]['text'])
  return question
Add entity links for this question.
language/labs/drkit/metaqa/preprocessing/metaqa_preprocess.py