<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _reduce_diff_results(self, matches_path, tokenizer, output_fh):
 """Returns `output_fh` populated with a reduced set of data from `matches_fh`. Diff results typically contain a lot of filler results that serve only to hide real differences. If one text has a single extra token than another, the diff between them will have results for every n-gram containing that extra token, which is not helpful. This method removes these filler results by 'reducing down' the results. :param matches_path: filepath or buffer of CSV results to be reduced :type matches_path: `str` or file-like object :param tokenizer: tokenizer for the n-grams :type tokenizer: `Tokenizer` :param output_fh: object to write results to :type output_fh: file-like object :rtype: file-like object """

        self._logger.info('Removing filler results')
        # For performance, perform the attribute accesses once.
        tokenize = tokenizer.tokenize
        join = tokenizer.joiner.join
        results = []
        previous_witness = (None, None)
        previous_data = {}
        # Calculate the index of ngram and count columns in a Pandas
        # named tuple row, as used below. The +1 is due to the tuple
        # having the row index as the first element.
        ngram_index = constants.QUERY_FIELDNAMES.index(
            constants.NGRAM_FIELDNAME) + 1
        count_index = constants.QUERY_FIELDNAMES.index(
            constants.COUNT_FIELDNAME) + 1
        # Operate over individual witnesses and sizes, so that there
        # is no possible results pollution between them.
        grouped = pd.read_csv(matches_path, encoding='utf-8',
                              na_filter=False).groupby(
            [constants.WORK_FIELDNAME, constants.SIGLUM_FIELDNAME,
             constants.SIZE_FIELDNAME])
        for (work, siglum, size), group in grouped:
            if (work, siglum) != previous_witness:
                previous_matches = group
                previous_witness = (work, siglum)
            else:
                self._logger.debug(
                    'Reducing down {} {}-grams for {} {}'.format(
                        len(group.index), size, work, siglum))
                if previous_matches.empty:
                    reduced_count = 0
                else:
                    previous_matches = group.apply(
                        self._check_diff_result, axis=1,
                        args=(previous_data, tokenize, join))
                    reduced_count = len(previous_matches[previous_matches[
                                        constants.COUNT_FIELDNAME] != 0].index)
                self._logger.debug('Reduced down to {} grams'.format(
                    reduced_count))
            # Put the previous matches into a form that is more
            # performant for the lookups made in _check_diff_result.
            previous_data = {}
            for row in previous_matches.itertuples():
                previous_data[row[ngram_index]] = row[count_index]
            if not previous_matches.empty:
                results.append(previous_matches[previous_matches[
                    constants.COUNT_FIELDNAME] != 0])
        reduced_results = pd.concat(results, ignore_index=True).reindex(
            columns=constants.QUERY_FIELDNAMES)
        reduced_results.to_csv(output_fh, encoding='utf-8', float_format='%d',
                               index=False)
        return output_fh