<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_label_work_count(self):
 """Adds to each result row a count of the number of works within the label contain that n-gram. This counts works that have at least one witness carrying the n-gram. This correctly handles cases where an n-gram has only zero counts for a given work (possible with zero-fill followed by filtering by maximum count). """

        self._logger.info('Adding label work count')

        def add_label_text_count(df):
            work_maxima = df.groupby(constants.WORK_FIELDNAME,
                                     sort=False).any()
            df.loc[:, constants.LABEL_WORK_COUNT_FIELDNAME] = work_maxima[
                constants.COUNT_FIELDNAME].sum()
            return df

        if self._matches.empty:
            self._matches[constants.LABEL_WORK_COUNT_FIELDNAME] = 0
        else:
            self._matches.loc[:, constants.LABEL_WORK_COUNT_FIELDNAME] = 0
            self._matches = self._matches.groupby(
                [constants.LABEL_FIELDNAME, constants.NGRAM_FIELDNAME],
                sort=False).apply(add_label_text_count)
        self._logger.info('Finished adding label work count')