def analyze(segments, analysis, lookup=dict(bipa={}, dolgo={})):
    if not segments:
        raise ValueError('Empty sequence.')
    if not [segment for segment in segments if segment.strip()]:
        raise ValueError('No information in the sequence.')
    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:
        print(segments)
        raise
    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
    for segment, sound_bipa, sound_class in zip(segments, bipa_analysis, sc_analysis):
        analysis.segments.update([segment])
        if isinstance(sound_bipa, pyclts.models.UnknownSound):
            analysis.bipa_errors.add(segment)
        else:
            analysis.replacements[sound_bipa.source].add(sound_bipa.__unicode__())
        if sound_class == '?':
            analysis.sclass_errors.add(segment)
    return segments, bipa_analysis, sc_analysis, analysis