def construct_membership(
      self, train_split):
    """Construct sets from KB.

    A natural set is defined as a set of entities that share the same
    property, e.g. movies directed by Nolan, or actors appear in Inception.

    Args:
      train_split: percentage of data for training

    Returns:
      a list of train sets and test sets
    """
    train_data = list()
    test_data = list()

    for unused_subj_id, subj in self.id2entity.items():
      all_objs = set()
      for _, objs in self.kb[subj].items():
        all_objs.update(objs)
      # Group entities by graph structure. Entities within distance one
      # are considered as an element in the set.
      if len(all_objs) > 1:
        one_data = all_objs
      else:
        continue

      if random.random() < train_split:
        train_data.append(one_data)
      else:
        test_data.append(one_data)

    tf.logging.info('set examples: %d train, %d test', len(train_data),
                    len(test_data))
    return train_data, test_data
Construct sets from KB.

    A natural set is defined as a set of entities that share the same
    property, e.g. movies directed by Nolan, or actors appear in Inception.

    Args:
      train_split: percentage of data for training

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