<commit_before>import itertools
from collections import defaultdict

import corpus_utils
import scorers

class Bucketer:

  def set_bucket_cutoffs(self, bucket_cutoffs, num_type='int'):
    self.bucket_cutoffs = bucket_cutoffs
    self.bucket_strs = []
    for i, x in enumerate(bucket_cutoffs):
      if i == 0:
        self.bucket_strs.append(f'x < {x}')
      elif num_type == 'int' and x-1 == bucket_cutoffs[i-1]:
        self.bucket_strs.append(f'x = {x-1}')
      else:
        self.bucket_strs.append(f'{bucket_cutoffs[i-1]} <= x < {x}')
      last_start = x
    self.bucket_strs.append(f'{bucket_cutoffs[i-1]} < x')

  def cutoff_into_bucket(self, value):
    for i, v in enumerate(self.bucket_cutoffs):<commit_msg>Fix bug in bucketers<commit_after>import itertools
from collections import defaultdict

import corpus_utils
import scorers

class Bucketer:

  def set_bucket_cutoffs(self, bucket_cutoffs, num_type='int'):
    self.bucket_cutoffs = bucket_cutoffs
    self.bucket_strs = []
    for i, x in enumerate(bucket_cutoffs):
      if i == 0:
        self.bucket_strs.append(f'x < {x}')
      elif num_type == 'int' and x-1 == bucket_cutoffs[i-1]:
        self.bucket_strs.append(f'x = {x-1}')
      else:
        self.bucket_strs.append(f'{bucket_cutoffs[i-1]} <= x < {x}')
    self.bucket_strs.append(f'{x} < x')

  def cutoff_into_bucket(self, value):
    for i, v in enumerate(self.bucket_cutoffs):
{'fraction_non_alphanumeric': 0.13012729844413012, 'fraction_numerical': 0.007779349363507779, 'mean_word_length': 3.6241830065359477, 'pattern_counts': {'":': 0, '<': 11, '<?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': '7166429', 'n_tokens_mistral': 527, 'n_tokens_neox': 512, 'n_words': 106}