code: def consistency_check(text, word_pairs, err, msg, offset=0):
      
      errors = []
  
      msg = " ".join(msg.split())
  
      for w in word_pairs:
          matches = [
              [m for m in re.finditer(w[0], text)],
              [m for m in re.finditer(w[1], text)]
          ]
  
          if len(matches[0]) > 0 and len(matches[1]) > 0:
  
              idx_minority = len(matches[0]) > len(matches[1])
  
              for m in matches[idx_minority]:
                  errors.append((
                      m.start() + offset,
                      m.end() + offset,
                      err,
                      msg.format(w[~idx_minority], m.group(0)),
                      w[~idx_minority]))
  
      return errors
docs: Build a consistency checker for the given word_pairs.