docs: def _process_witness(self, witness, matches):
          """Return the counts of total tokens and matching tokens in `witness`.
  
          :param witness: witness text
          :type witness: `tacl.WitnessText`
          :param matches: n-gram matches
          :type matches: `pandas.DataFrame`
          :rtype: `tuple` of `int`
  
          """
          # In order to provide a correct count of matched tokens,
          # avoiding the twin dangers of counting the same token
          # multiple times due to being part of multiple n-grams (which
          # can happen even in reduced results) and not counting tokens
          # due to an n-gram overlapping with itself or another n-gram,
          # a bit of work is required.
          #
          # Using regular expressions, get the slice indices for all
          # matches (including overlapping ones) for all matching
          # n-grams. Merge these slices together (without overlap) and
          # create a Text using that text, which can then be tokenised
          # and the tokens counted.
          tokens = witness.get_tokens()
          full_text = witness.get_token_content()
          fields = [constants.NGRAM_FIELDNAME, constants.SIZE_FIELDNAME]
          match_slices = []
          for index, (ngram, size) in matches[fields].iterrows():
              pattern = re.compile(re.escape(ngram))
              # Because the same n-gram may overlap itself ("heh" in the
              # string "heheh"), re.findall cannot be used.
              start = 0
              while True:
                  match = pattern.search(full_text, start)
                  if match is None:
                      break
                  match_slices.append([match.start(), match.end()])
                  start = match.start() + 1
          merged_slices = self._merge_slices(match_slices)
          match_content = self._generate_text_from_slices(
              full_text, merged_slices)
          match_text = Text(match_content, self._tokenizer)
          return len(tokens), len(match_text.get_tokens())