<commit_before>import re

from django.template import Library


register = Library()


@register.filter
def message_bootstrap_class_str(message):
    return ' '.join('alert-' + tag for tag in message.tags.split(' '))


@register.filter
def get_path_category(url):
    lang = '\/(zh\-hant|en\-us)'
    category_pattern_mapping = {
        'about': '\/about/pycontw',
        'sponsor': '\/sponsor/sponsor',
        'speaking': '\/speaking\/(cfp|talk|tutorial|recording)',
        'conference': '\/(events\/(overview|schedule)|portal)',
        'event': '\/events\/(keynotes|talks|open-spaces)',
        'registration': '\/registration/(financial-aid|ticket-info|registration)',
        'venue': '\/venue'
    }
    end = '\/?$'
    for category, pattern in category_pattern_mapping.items():
        if re.match(lang + pattern + end, url):
            return category
    return 'uncategorized'
<commit_msg>Remove interdependence from get_path_category()<commit_after>import re

from django.template import Library


register = Library()


@register.filter
def message_bootstrap_class_str(message):
    return ' '.join('alert-' + tag for tag in message.tags.split(' '))


@register.filter
def get_path_category(url):
    pattern = r'/(?P<lang>zh\-hant|en\-us)/(?P<category>[0-9a-z-]*)/'
    result = re.match(pattern, url)
    if not result:
        return 'unmatched'
    return result.groupdict().get('category', 'uncategorized')

{'fraction_non_alphanumeric': 0.16363636363636364, 'fraction_numerical': 0.0013986013986013986, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5614274', 'n_tokens_mistral': 466, 'n_tokens_neox': 449, 'n_words': 90}