'Load an annotation set from a sentence in an subcorpus of an LU'

def _handle_luannotationset_elt(self, elt, is_pos=False):

    info = self._load_xml_attributes(AttrDict(), elt)
    info[u'_type'] = (u'posannotationset' if is_pos else u'luannotationset')
    info[u'layer'] = []
    info[u'_ascii'] = types.MethodType(_annotation_ascii, info)
    if (u'cxnID' in info):
        return info
    for sub in elt:
        if sub.tag.endswith(u'layer'):
            l = self._handle_lulayer_elt(sub)
            if (l is not None):
                overt = []
                ni = {}
                info[u'layer'].append(l)
                for lbl in l.label:
                    if (u'start' in lbl):
                        thespan = (lbl.start, (lbl.end + 1), lbl.name)
                        if (l.name not in (u'Sent', u'Other')):
                            assert (thespan not in overt), (info.ID, l.name, thespan)
                        overt.append(thespan)
                    elif (lbl.name in ni):
                        self._warn(u'FE    with    multiple    NI    entries:', lbl.name, ni[lbl.name], lbl.itype)
                    else:
                        ni[lbl.name] = lbl.itype
                overt = sorted(overt)
                if (l.name == u'Target'):
                    if (not overt):
                        self._warn(u'Skipping    empty    Target    layer    in    annotation    set    ID={0}'.format(info.ID))
                        continue
                    assert all(((lblname == u'Target') for (i, j, lblname) in overt))
                    if (u'Target' in info):
                        self._warn(u'Annotation    set    {0}    has    multiple    Target    layers'.format(info.ID))
                    else:
                        info[u'Target'] = [(i, j) for (i, j, _) in overt]
                elif (l.name == u'FE'):
                    if (l.rank == 1):
                        assert (u'FE' not in info)
                        info[u'FE'] = (overt, ni)
                    else:
                        assert (2 <= l.rank <= 3), l.rank
                        k = (u'FE' + str(l.rank))
                        assert (k not in info)
                        info[k] = (overt, ni)
                elif (l.name in (u'GF', u'PT')):
                    assert (l.rank == 1)
                    info[l.name] = overt
                elif (l.name in (u'BNC', u'PENN')):
                    assert (l.rank == 1)
                    info[u'POS'] = overt
                    info[u'POS_tagset'] = l.name
                else:
                    if is_pos:
                        if (l.name not in (u'NER', u'WSL')):
                            self._warn(u'Unexpected    layer    in    sentence    annotationset:', l.name)
                    elif (l.name not in (u'Sent', u'Verb', u'Noun', u'Adj', u'Adv', u'Prep', u'Scon', u'Art', u'Other')):
                        self._warn(u'Unexpected    layer    in    frame    annotationset:', l.name)
                    info[l.name] = overt
    if ((not is_pos) and (u'cxnID' not in info)):
        if (u'Target' not in info):
            self._warn(u'Missing    target    in    annotation    set    ID={0}'.format(info.ID))
        assert (u'FE' in info)
        if (u'FE3' in info):
            assert (u'FE2' in info)
    return info
