import re


def iob2etype(lines, iob=False):
    """
    Change iob format to etype: for example, I-DRUG to DRUG
    """
    start_indicator = '-DOCSTART-'
    p = re.compile(r'([IB])-(\w+)')
    res = []
    sent = []
    labels = []
    for l in lines:
        l = l.strip()
        if len(l) > 0 and start_indicator not in l:
            w, label = l.split()
            sent.append(w)
            match = p.match(label)
            if match:
                if iob:
                    label = match.group(0)
                else:
                    label = match.group(2)
            labels.append(label)
        elif len(sent) > 0:
            res.append((sent, labels))
            sent = []
            labels = []
    if len(sent) > 0:
        res.append((sent, labels))
    return res