docs: def analyze(segments, analysis, lookup=dict(bipa={}, dolgo={})):
      """
      Test a sequence for compatibility with CLPA and LingPy.
  
      :param analysis: Pass a `TranscriptionAnalysis` instance for cumulative reporting.
      """
      # raise a ValueError in case of empty segments/strings
      if not segments:
          raise ValueError('Empty sequence.')
  
      # test if at least one element in `segments` has information
      # (helps to catch really badly formed input, such as ['\n']
      if not [segment for segment in segments if segment.strip()]:
          raise ValueError('No information in the sequence.')
  
      # build the phonologic and sound class analyses
      try:
          bipa_analysis, sc_analysis = [], []
          for s in segments:
              a = lookup['bipa'].get(s)
              if a is None:
                  a = lookup['bipa'].setdefault(s, BIPA[s])
              bipa_analysis.append(a)
  
              sc = lookup['dolgo'].get(s)
              if sc is None:
                  sc = lookup['dolgo'].setdefault(s, BIPA.translate(s, DOLGO))
              sc_analysis.append(sc)
      except:  # noqa
          print(segments)
          raise
  
      # compute general errors; this loop must take place outside the
      # following one because the code for computing single errors (either
      # in `bipa_analysis` or in `soundclass_analysis`) is unnecessary
      # complicated
      for sound_bipa, sound_class in zip(bipa_analysis, sc_analysis):
          if isinstance(sound_bipa, pyclts.models.UnknownSound) or sound_class == '?':
              analysis.general_errors += 1
  
      # iterate over the segments and analyses, updating counts of occurrences
      # and specific errors
      for segment, sound_bipa, sound_class in zip(segments, bipa_analysis, sc_analysis):
          # update the segment count
          analysis.segments.update([segment])
  
          # add an error if we got an unknown sound, otherwise just append
          # the `replacements` dictionary
          if isinstance(sound_bipa, pyclts.models.UnknownSound):
              analysis.bipa_errors.add(segment)
          else:
              analysis.replacements[sound_bipa.source].add(sound_bipa.__unicode__())
  
          # update sound class errors, if any
          if sound_class == '?':
              analysis.sclass_errors.add(segment)
  
      return segments, bipa_analysis, sc_analysis, analysis