def _get_trimmed_relations(self):
    """Gets a mapping between relations and their short naming."""
    relations = set()
    for example in self.train_examples:
      tokens = example.program.split()
      for token in tokens:
        if "." in token and token != ".":  # Identify tokens that are relations.
          relations.add(token)

    trimmed_relations = {}
    relations_original = set(relations)
    for relation in relations_original:
      # Trim relations that contain "ns:".
      if "ns:" in relation and not relation.startswith("#"):
        relation_trimmed = relation.split("ns:")[-1]
        if relation_trimmed in relations:
          raise RuntimeError(
              "The trimmed relation {} is not unique!".format(relation_trimmed))
        relations.add(relation_trimmed)
        trimmed_relations[relation] = relation_trimmed
    return trimmed_relations
Gets a mapping between relations and their short naming.
language/compir/dataset_parsers/cfq_parser.py