def get_conjuncts_reversible(
        subj_rel_to_objects,
        subj_objs_to_rels):
      """Generates conjuncts in their reversible intermediate representation."""
      conjuncts_reversible = []
      added_subj_objs = []
      for subj_rel, objects in subj_rel_to_objects.items():
        if objects is None:  # Only wrap the conjunct with parentheses.
          conjuncts_reversible.append("( {} )".format(subj_rel))
        else:
          # Prepare conjunct in the form of (s , (r_1 r_2 ...) (o_1 , o_2 ...)).
          subj, _ = subj_rel
          objects_tup = tuple(objects)
          if (objects_tup, subj) in added_subj_objs:
            # Already handled the conjuncts with this subject and objects list.
            continue
          else:
            added_subj_objs.append((objects_tup, subj))
          conjunct_reversible = "( {} ( {} ) ( {} ) )".format(
              subj, " , ".join(subj_objs_to_rels[(objects_tup, subj)]),
              " , ".join(objects))
          conjuncts_reversible.append(conjunct_reversible)
      return conjuncts_reversible
Generates conjuncts in their reversible intermediate representation.
language/compir/dataset_parsers/cfq_parser.py