<commit_before>import traceback


def generate_knapsack(items_dict, constraint_value):
    items = sorted(items_dict.items(), key=lambda x:x[1], reverse=True)

    return _compute_greedy_knapsack(items, constraint_value, [])


def _compute_greedy_knapsack(items, constraint_value, knapsack_collection):
    bag_of_items = []
    knaspack_weight = 0

    idx = 0
    while idx < len(items):
        if knaspack_weight > constraint_value:
            break

        cow = items[idx]
        name, weight = cow
        verification_weight = knaspack_weight + weight

        if verification_weight <= constraint_value:
            bag_of_items.append(name)
            items.pop(idx)
            knaspack_weight = verification_weight
        else:
            idx += 1<commit_msg>fixed variable name<commit_after>import traceback


def generate_knapsack(items_dict, constraint_value):
    items = sorted(items_dict.items(), key=lambda x:x[1], reverse=True)

    return _compute_greedy_knapsack(items, constraint_value, [])


def _compute_greedy_knapsack(items, constraint_value, knapsack_collection):
    bag_of_items = []
    knaspack_weight = 0

    idx = 0
    while idx < len(items):
        if knaspack_weight > constraint_value:
            break

        item = items[idx]
        name, weight = item
        verification_weight = knaspack_weight + weight

        if verification_weight <= constraint_value:
            bag_of_items.append(name)
            items.pop(idx)
            knaspack_weight = verification_weight
        else:
            idx += 1
{'fraction_non_alphanumeric': 0.0793854033290653, 'fraction_numerical': 0.005121638924455826, 'mean_word_length': 2.802919708029197, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4198352', 'n_tokens_mistral': 477, 'n_tokens_neox': 457, 'n_words': 95}