<commit_before>_default = object()


class Hash(object):
    def __init__(self, buckets=1024):
        self.table = [[] for i in range(buckets)]
        self.buckets = buckets

    def hash(self, key):
        hash_key = reduce(lambda x, y: ord(x) + ord(y), key)
        return hash_key % self.buckets

    def _get_bucket(self, key):
        index = self.hash(key)
        return self.table(index)

    def _get_kvpair(self, key):
        bucket = self.get_bucket(key)
        for i, pair in enumerate(bucket):
            k, v = pair
            if key == i:
                return i, k, v
        return -1, key, _default

    def get(self, key):
        i, k, v = self._get_kvpair(self.table, key)
        if v is _default:
            raise KeyError('Key does not exist')
        return v

    def set(self, key, value):
        if type(key) is not str:
            raise TypeError('Key must be string!')
        bucket = self._get_bucket(self.table, key)
        i, k, v = self._get_kvpair(self.table, key)<commit_msg>Add and pass tests<commit_after>_default = object()


class Hash(object):
    def __init__(self, buckets=1024):
        self.table = [[] for i in range(buckets)]
        self.buckets = buckets

    def hash(self, key):
        hash_key = sum([ord(c) for c in key])
        return hash_key % self.buckets

    def _get_bucket(self, key):
        index = self.hash(key)
        return self.table[index]

    def _get_kvpair(self, key):
        bucket = self._get_bucket(key)
        for i, pair in enumerate(bucket):
            k, v = pair
            if key == k:
                return i, k, v
        return -1, key, _default

    def get(self, key):
        i, k, v = self._get_kvpair(key)
        if v is _default:
            raise KeyError('Key does not exist')
        return v

    def set(self, key, value):
        if type(key) is not str:
            raise TypeError('Key must be string!')
        bucket = self._get_bucket(key)
        i, k, v = self._get_kvpair(key)
{'fraction_non_alphanumeric': 0.11283075386919621, 'fraction_numerical': 0.004992511233150275, 'mean_word_length': 1.9644970414201184, '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': '1926362', 'n_tokens_mistral': 663, 'n_tokens_neox': 629, 'n_words': 196}