def get_number_rules(source, target):
  """Return number seed rules based on exact match."""
  rules = set()

  # First, match numbers without decimals.
  matches = re.findall(r"Number ([0-9]+?) ", target)
  for match in matches:
    if match not in source:
      print("`%s` is not in `%s`." % (match, source))
      continue
    target_rhs = "Number %s" % match
    source_rhs = match
    rules.add(
        qcfg_rule.QCFGRule(
            tuple(source_rhs.split(" ")), tuple(target_rhs.split(" ")), 0))

  # Second, try to match numbers with 0 as decimal.
  matches = re.findall(r"Number ([0-9]+?).0 ", target)
  for match in matches:
    if match not in source:
      continue
    target_rhs = "Number %s.0" % match
    source_rhs = match
    rules.add(
        qcfg_rule.QCFGRule(
            tuple(source_rhs.split(" ")), tuple(target_rhs.split(" ")), 0))

  # Finally, match numbers with decimals.
  matches = re.findall(r"Number ([0-9]+\.[0-9]+?) ", target)
  for match in matches:
    if match not in source:
      print("`%s` is not in `%s`." % (match, source))
      continue
    target_rhs = "Number %s" % match
    source_rhs = match
    rules.add(
        qcfg_rule.QCFGRule(
            tuple(source_rhs.split(" ")), tuple(target_rhs.split(" ")), 0))

  return rules
Return number seed rules based on exact match.
language/compgen/csl/tasks/smcalflow/tools/generate_identity_rules.py