<commit_before>from sqlite3 import Connection, Row


class Decoder:
    def __init__(self):
        self.conn = Connection('nes.sqlite')
        self.conn.row_factory = Row

    def __del__(self):
        self.conn.close()

    def decode(self, opcode):
        c = self.conn.cursor()
        c.execute('select * from instruction where opcode=?', [opcode])
        row = c.fetchone()
        return dict(zip(row.keys(), row))<commit_msg>Raise an exception when it's an undocumented opcode.<commit_after>from sqlite3 import Connection, Row


class Decoder:
    def __init__(self):
        self.conn = Connection('nes.sqlite')
        self.conn.row_factory = Row

    def __del__(self):
        self.conn.close()

    def decode(self, opcode):
        c = self.conn.cursor()
        c.execute('select * from instruction where opcode=?', [opcode])
        row = c.fetchone()
        if row:
            return dict(zip(row.keys(), row))
        else:
            raise NotImplementedError('Undocumented Opcode: ' + str(opcode))
{'fraction_non_alphanumeric': 0.123046875, 'fraction_numerical': 0.001953125, 'mean_word_length': 2.5590277777777777, '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': '3579619', 'n_tokens_mistral': 311, 'n_tokens_neox': 302, 'n_words': 77}