def get_exact_match_rules(dataset):
  """Return set of rules for terminal sequences in both source and target."""

  matches = set()
  for source_str, target_str in dataset:
    source = source_str.split()
    target = target_str.split()
    matches.update(_find_exact_matches(source, target))

  exact_match_rules = set()
  for match in matches:
    rule = qcfg_rule.QCFGRule(source=tuple(match), target=tuple(match), arity=0)
    exact_match_rules.add(rule)

  return exact_match_rules
Return set of rules for terminal sequences in both source and target.
language/compgen/csl/tasks/exact_match_utils.py