docs: def _set_labels(self, catalogue):
          """Returns a dictionary of the unique labels in `catalogue` and the
          count of all tokens associated with each, and sets the record
          of each Text to its corresponding label.
  
          Texts that do not have a label specified are set to the empty
          string.
  
          Token counts are included in the results to allow for
          semi-accurate sorting based on corpora size.
  
          :param catalogue: catalogue matching filenames to labels
          :type catalogue: `Catalogue`
          :rtype: `dict`
  
          """
          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