def construct_set_follow_facts(
      self, train_split):
    """Construct datasets from KB that a set of entities follow a relation.

    Note that the results of a set-follow operation can be multiple entities.
    For example, given a natural set of movies that stars Robert Downey Jr.,
    and a relation "stars", the results are all actors who co-star with
    Robert Downey Jr. in some movies.

    Args:
      train_split: percentage of data for training

    Returns:
      a list of train pairs and test pairs
    """
    random.seed(SEED)
    subj2factids = dict()
    rel2factids = dict()
    for subj, facts in self.kb.items():
      if subj not in subj2factids:
        subj2factids[subj] = set()
      for rel, objs in facts.items():
        if rel not in rel2factids:
          rel2factids[rel] = set()
        factids = [self.fact2id[(subj, rel, obj)] for obj in objs]
        subj2factids[subj].update(factids)
        rel2factids[rel].update(factids)

    train_facts = list()
    test_facts = list()
    for subj, facts in self.kb.items():
      for rel, objs in facts.items():
        # For convenience, we take the object and inverse relation as samples.
        if len(objs) <= 1:
          continue
        subj_factids = set().union(*[subj2factids[obj] for obj in objs])
        rel_factids = rel2factids[self._inverse_rel(rel)]
        if random.random() < train_split:
          train_facts.append((subj_factids, rel_factids))
        else:
          test_facts.append((subj_factids, rel_factids))
    tf.logging.info('set_follow examples: %d train, %d test',
                    len(train_facts), len(test_facts))
    return train_facts, test_facts
Construct datasets from KB that a set of entities follow a relation.

    Note that the results of a set-follow operation can be multiple entities.
    For example, given a natural set of movies that stars Robert Downey Jr.,
    and a relation "stars", the results are all actors who co-star with
    Robert Downey Jr. in some movies.

    Args:
      train_split: percentage of data for training

    Returns:
      a list of train pairs and test pairs
    
language/emql/data_loader.py