def _find_relevant_examples(dataset, rule):
  """Find examples in `dataset` where `rule` could be used in a derivation."""
  # TODO(petershaw): This could potentially be more effecient by pre-indexing
  # the dataset sources in a data structure such as a Trie.
  examples = []
  for source_str, target_str in dataset:
    source = source_str.split()
    target = target_str.split()
    if rule_utils.rhs_can_maybe_derive(rule.source, source):
      examples.append((source, target))
  return examples
Find examples in `dataset` where `rule` could be used in a derivation.
language/compgen/nqg/model/induction/codelength_utils.py