import re


def parse_original(original_file):
    """Parse original wikitable content into a dictionary, keyed by atoms"""
    words = {}
    key = None
    pending = []
    # <nowiki> tags are optional. Meant to extract the text inside the
    # template.
    pat = re.compile(r'\| \{\{ALB\|(?:<nowiki>)?([^<>]*)(?:</nowiki>)?\}\}')
    pat2 = re.compile(r'\| ?(.*)')
    for line in original_file:
        line = line.rstrip()
        if line == '|-':
            if key is not None:
                if key in words:
                    pending = words[key] + ["*duplicate*"] + pending
                words[key] = pending
                key = None
                pending = []
            continue
        if key is None:
            match = pat.fullmatch(line)
            if not match:
                raise ValueError("Couldn't match " + line)
            key = match[1]
        else:
            match = pat2.fullmatch(line)
            if not match:
                raise ValueError("Couldn't match " + line)
            pending.append(match[1])
    if key is not None:
        if key in words:
            pending = words[key] + ["*duplicate*"] + pending
        words[key] = pending
    return words