def serialize_query(self, global_para_id, ment_index_to_para_index, subj_id,
                      subj_mentions, property_id, tail_id, tail_mention,
                      ctx_type):
    """Create JSON object with distantly supervised fact."""
    subject = {
        "wikidata_id": subj_id,
        "aliases": self.get_aliases(subj_id),
        "mentions": [ment_index_to_para_index[ix] for ix in subj_mentions],
    }
    if property_id not in self.property_names:
      print("did not find", property_id, "in names")
    relation = {
        "wikidata_id": property_id,
        "text": self.property_names.get(property_id, property_id)
    }
    if tail_id is None:
      obj = None
      id_ = subj_id + "_" + property_id + "_None"
    else:
      obj = {
          "wikidata_id": tail_id,
          "aliases": self.get_aliases(tail_id),
          "mention": ment_index_to_para_index[tail_mention],
      }
      id_ = subj_id + "_" + property_id + "_" + str(tail_id)
    serialized = json.dumps({
        "id": id_,
        "para_id": global_para_id,
        "subject": subject,
        "relation": relation,
        "object": obj,
        "context_type": ctx_type,
    })
    return serialized
Create JSON object with distantly supervised fact.
language/labs/drkit/wikidata/preprocessing/distantly_supervise.py