<commit_before>import json

from utils import assert_index_sane
import bread
import bread_spec

from synth import Synth
from table import Table
from phrase import Phrase
from chain import Chain
from speech_instrument import SpeechInstrument

from wave_instrument import WaveInstrument
from pulse_instrument import PulseInstrument
from kit_instrument import KitInstrument
from noise_instrument import NoiseInstrument

from bread_spec import INSTRUMENT_TYPE_CODE
from filepack import DEFAULT_INSTRUMENT

from clock import Clock, TotalClock

import StringIO

# Number of channels
NUM_CHANNELS = 4


class AllocTable(object):

    def __init__(self, song, alloc_table, object_class):
        self.alloc_table = alloc_table

        self.access_objects = []

        for index in xrange(len(alloc_table)):
            self.access_objects.append(object_class(song, index))

    def __getitem__(self, index):
        assert_index_sane(index, len(self.alloc_table))

        if not self.alloc_table[index]:
            return None

        return self.access_objects[index]

    def allocate(self, index):
        self.alloc_table[index] = True
<commit_msg>Add missing exception import in song.py<commit_after>import json

from utils import assert_index_sane
import bread
import bread_spec

from synth import Synth
from table import Table
from phrase import Phrase
from chain import Chain
from speech_instrument import SpeechInstrument

from wave_instrument import WaveInstrument
from pulse_instrument import PulseInstrument
from kit_instrument import KitInstrument
from noise_instrument import NoiseInstrument

from bread_spec import INSTRUMENT_TYPE_CODE
from filepack import DEFAULT_INSTRUMENT

from clock import Clock, TotalClock

import StringIO

from exceptions import ImportException

# Number of channels
NUM_CHANNELS = 4


class AllocTable(object):

    def __init__(self, song, alloc_table, object_class):
        self.alloc_table = alloc_table

        self.access_objects = []

        for index in xrange(len(alloc_table)):
            self.access_objects.append(object_class(song, index))

    def __getitem__(self, index):
        assert_index_sane(index, len(self.alloc_table))

        if not self.alloc_table[index]:
            return None

        return self.access_objects[index]

    def allocate(self, index):
        self.alloc_table[index] = True

{'fraction_non_alphanumeric': 0.04949238578680203, 'fraction_numerical': 0.0008460236886632825, 'mean_word_length': 4.209251101321586, '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': '5061573', 'n_tokens_mistral': 671, 'n_tokens_neox': 644, 'n_words': 207}