def _bracket_atomic_action(self, utterance, program):
    """Wraps atomic actions (without "and"/"after") with parentheses.

    Args:
      utterance: the question.
      program: a program where "twice" occurs exactly once, "thrice" occurs
        exactly once, or neither "twice" nor "thrice" occurs.

    Returns:
      The program with repeated actions (that repeat twice or thrice) wrapped
      with parenthesis.
    """

    program_tokens = program.split()
    num_program_tokens = len(program_tokens)
    if "twice" in utterance:
      # The repeated action consists of 1/2 of the tokens in the program.
      action_repeated = " ".join(program_tokens[:int(num_program_tokens / 2)])
      program_bracketed = "( {action} ) ( {action} )".format(
          action=action_repeated)
    elif "thrice" in utterance:
      # The repeated action consists of 1/3 of the tokens in the program.
      action_repeated = " ".join(program_tokens[:int(num_program_tokens / 3)])
      program_bracketed = "( {action} ) ( {action} ) ( {action} )".format(
          action=action_repeated)
    else:
      # There is no repeated action.
      program_bracketed = str(program)
    return program_bracketed
Wraps atomic actions (without "and"/"after") with parentheses.

    Args:
      utterance: the question.
      program: a program where "twice" occurs exactly once, "thrice" occurs
        exactly once, or neither "twice" nor "thrice" occurs.

    Returns:
      The program with repeated actions (that repeat twice or thrice) wrapped
      with parenthesis.
    
language/compir/dataset_parsers/scan_parser.py