def read_rules(filename):
  """Read rule txt file to list of rules."""
  rules = []
  with gfile.GFile(filename, "r") as txt_file:
    for line in txt_file:
      line = line.rstrip()
      rule = qcfg_rule.rule_from_string(line)
      rules.append(rule)
  print("Loaded %s rules from %s." % (len(rules), filename))
  return rules
Read rule txt file to list of rules.
language/compgen/nqg/model/qcfg/qcfg_file.py