<commit_before>import re


class RegexFactory(object):
    """Generates a regex pattern."""
    WORD_GROUP = '({0}|\*)'
    SEP = '/'

    def _generate_pattern(self, path):
        """Generates a regex pattern."""
        # Split the path up into a list using the forward slash as a
        # delimiter.
        words = (word for word in path.split(self.SEP) if word)

        # Compose a list of regular expression groups for each word in
        # the path.
        patterns = (self.WORD_GROUP.format(re.escape(word)) for word in words)

        # Implode the list into a single regex pattern that will match
        # the path pattern format.
        return '^{0}$'.format(('\,').join(patterns))

    def create(self, path):
        pattern = self._generate_pattern(path)
        return re.compile(pattern, re.ASCII | re.MULTILINE)<commit_msg>Make create a class method.<commit_after>import re


class RegexFactory(object):
    """Generates a regex pattern."""
    WORD_GROUP = '({0}|\*)'
    SEP = '/'

    def _generate_pattern(self, path):
        """Generates a regex pattern."""
        # Split the path up into a list using the forward slash as a
        # delimiter.
        words = (word for word in path.split(self.SEP) if word)

        # Compose a list of regular expression groups for each word in
        # the path.
        patterns = (self.WORD_GROUP.format(re.escape(word)) for word in words)

        # Implode the list into a single regex pattern that will match
        # the path pattern format.
        return '^{0}$'.format(('\,').join(patterns))

    @classmethod
    def create(cls, path):
        rf = cls()
        pattern = rf._generate_pattern(path)
        return re.compile(pattern, re.ASCII | re.MULTILINE)
{'fraction_non_alphanumeric': 0.11430212521539346, 'fraction_numerical': 0.0022975301550832855, 'mean_word_length': 2.497991967871486, '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': '5866932', 'n_tokens_mistral': 516, 'n_tokens_neox': 498, 'n_words': 176}