<commit_before><?php
    $admin_categories = array('hp_lead', 'hp_featured', 'hp_recent', 'sponsored');
    $meta_categories = array('featured', 'hp_lead', 'hp_featured', 'hp_recent', 'sponsored');

    // Helper function for getting post categories.
    function get_post_categories($post, $without = NULL, $limit = NULL) {
        if ($without === NULL)
            $without = $meta_categories;
        $categories = get_the_category($post);
        if ($without || $limit)
            $categories = reduce_categories($categories, $without, $limit);

        return $categories;
    }

    function get_primary_category($post, $without = NULL) {
        if ($without === NULL)
            $without = $meta_categories;
        $primary_category_data = simple_fields_value('primary_category', $post);
        if ($primary_category_data && $primary_category_data['selected_value']) {
            $primary_category = get_term_by('name', $primary_category_data['selected_value'], 'category');
        } else {
            $primary_category = get_post_categories($post, $without, 1);
        }

        return $primary_category;
    }

    // Helper function for reducing an array of categories to a certain length and/or a certain slug.
    function reduce_categories($categories, $without = NULL, $limit = NULL) {
        if ($without) {
            foreach ($categories as $index => $category) {
                if (in_array($category->slug, $without))
                    unset($categories[$index]);
            }
        }

        if ($limit)
            $categories = array_slice($categories, 0, $limit);

        if (!$categories)
            return NULL;

        if (count($categories) == 1 and $limit === 1)
            return $categories[0];

        return $categories;<commit_msg>Messed up some category filtering<commit_after><?php
    $admin_categories = array('hp_lead', 'hp_featured', 'hp_recent', 'sponsored');
    $meta_categories = array('featured', 'hp_lead', 'hp_featured', 'hp_recent', 'sponsored');

    // Helper function for getting post categories.
    function get_post_categories($post, $without = NULL, $limit = NULL) {
        global $meta_categories;
        if ($without === NULL)
            $without = $meta_categories;

        $categories = get_the_category($post);
        if ($without || $limit)
            $categories = reduce_categories($categories, $without, $limit);

        return $categories;
    }

    function get_primary_category($post, $without = NULL) {
        global $meta_categories;
        if ($without === NULL)
            $without = $meta_categories;
        $primary_category_data = simple_fields_value('primary_category', $post);
        if ($primary_category_data && $primary_category_data['selected_value']) {
            $primary_category = get_term_by('name', $primary_category_data['selected_value'], 'category');
        } else {
            $primary_category = get_post_categories($post, $without, 1);
        }

        return $primary_category;
    }

    // Helper function for reducing an array of categories to a certain length and/or a certain slug.
    function reduce_categories($categories, $without = NULL, $limit = NULL) {
        if ($without) {
            foreach ($categories as $index => $category) {
                if (in_array($category->slug, $without))
                    unset($categories[$index]);
            }
        }

        if ($limit)
            $categories = array_slice($categories, 0, $limit);

        if (!$categories)
            return NULL;

        if (count($categories) == 1 and $limit === 1)
            return $categories[0];

        return $categories;
{'fraction_non_alphanumeric': 0.12871557131169895, 'fraction_numerical': 0.002727024815925825, 'mean_word_length': 2.631683168316832, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6521180', 'n_tokens_mistral': 1008, 'n_tokens_neox': 964, 'n_words': 245}