docs: def extend(self, corpus):
          """Adds rows for all longer forms of n-grams in the results that are
          present in the witnesses.
  
          This works with both diff and intersect results.
  
          :param corpus: corpus of works to which results belong
          :type corpus: `Corpus`
  
          """
          self._logger.info('Extending results')
          if self._matches.empty:
              return
          highest_n = self._matches[constants.SIZE_FIELDNAME].max()
          if highest_n == 1:
              self._logger.warning(
                  'Extending results that contain only 1-grams is unsupported; '
                  'the original results will be used')
              return
          # Determine if we are dealing with diff or intersect
          # results. In the latter case, we need to perform a reciprocal
          # remove as the final stage (since extended n-grams may exist
          # in works from more than one label). This test will think
          # that intersect results that have had all but one label
          # removed are difference results, which will cause the results
          # to be potentially incorrect.
          is_intersect = self._is_intersect_results(self._matches)
          # Supply the extender with only matches on the largest
          # n-grams.
          matches = self._matches[
              self._matches[constants.SIZE_FIELDNAME] == highest_n]
          extended_matches = pd.DataFrame(columns=constants.QUERY_FIELDNAMES)
          cols = [constants.WORK_FIELDNAME, constants.SIGLUM_FIELDNAME,
                  constants.LABEL_FIELDNAME]
          for index, (work, siglum, label) in \
                  matches[cols].drop_duplicates().iterrows():
              extended_ngrams = self._generate_extended_ngrams(
                  matches, work, siglum, label, corpus, highest_n)
              extended_matches = pd.concat(
                  [extended_matches, self._generate_extended_matches(
                      extended_ngrams, highest_n, work, siglum, label)],
                  sort=False)
              extended_ngrams = None
          if is_intersect:
              extended_matches = self._reciprocal_remove(extended_matches)
          self._matches = self._matches.append(
              extended_matches, ignore_index=True).reindex(
                  columns=constants.QUERY_FIELDNAMES)