<commit_before>#!/usr/bin/python3
import cgum
import cgum.diff

def star(f):
      return lambda args: f(*args)

class RepairAction(object):
    pass

class RepairActionMiner(object):
    def __init__(self):
        self.__action_types = [DeleteStatement,
                               InsertStatement,
                               ModifyStatement,
                               WrapStatement,
                               UnwrapStatement,
                               ReplaceIfCondition,
                               ReplaceThenBranch]

    # Returns a dict of all repair actions within a given AST, aggregated by
    # type
    def mine(self, patch):
        stmts_bef =\
            patch.before().collect(lambda n: isinstance(n, cgum.statement.Statement))
        stmts_aft =\
            patch.after().collect(lambda n: isinstance(n, cgum.statement.Statement))

        actions = {}
        for action_type in self.__action_types:
            print("Finding actions of type: %s" % action_type)
            action_type.detect(patch, stmts_bef, stmts_aft, actions)
            print("- found %d actions of type: %s" % (len(actions[action_type.__name__]), action_type))
        return actions

# Detects a deleted statement
class DeleteStatement(RepairAction):
    @staticmethod<commit_msg>integrated replace else branch<commit_after>#!/usr/bin/python3
import cgum
import cgum.diff

def star(f):
      return lambda args: f(*args)

class RepairAction(object):
    pass

class RepairActionMiner(object):
    def __init__(self):
        self.__action_types = [DeleteStatement,
                               InsertStatement,
                               ModifyStatement,
                               WrapStatement,
                               UnwrapStatement,
                               ReplaceIfCondition,
                               ReplaceThenBranch,
                               ReplaceElseBranch]

    # Returns a dict of all repair actions within a given AST, aggregated by
    # type
    def mine(self, patch):
        stmts_bef =\
            patch.before().collect(lambda n: isinstance(n, cgum.statement.Statement))
        stmts_aft =\
            patch.after().collect(lambda n: isinstance(n, cgum.statement.Statement))

        actions = {}
        for action_type in self.__action_types:
            print("Finding actions of type: %s" % action_type)
            action_type.detect(patch, stmts_bef, stmts_aft, actions)
            print("- found %d actions of type: %s" % (len(actions[action_type.__name__]), action_type))
        return actions

# Detects a deleted statement
class DeleteStatement(RepairAction):
    @staticmethod
{'fraction_non_alphanumeric': 0.0827405466117559, 'fraction_numerical': 0.0007487832272557095, 'mean_word_length': 1.8917748917748918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2311661', 'n_tokens_mistral': 708, 'n_tokens_neox': 691, 'n_words': 175}