def _set_labels(self, catalogue):
        with self._conn:
            self._conn.execute(constants.UPDATE_LABELS_SQL, [''])
            labels = {}
            for work, label in catalogue.items():
                self._conn.execute(constants.UPDATE_LABEL_SQL, [label, work])
                cursor = self._conn.execute(
                    constants.SELECT_TEXT_TOKEN_COUNT_SQL, [work])
                token_count = cursor.fetchone()['token_count']
                labels[label] = labels.get(label, 0) + token_count
        return labels