'Normalize the xml sentence element in t.
The sentence elements <alpino_ds>, although embedded in a few overall
xml elements, are seperated by blank lines. That\'s how the reader can
deliver them one at a time.
Each sentence has a few category subnodes that are of no use to us.
The remaining word nodes may or may not appear in the proper order.
Each word node has attributes, among which:
- begin : the position of the word in the sentence
- pos   : Part of Speech: the Tag
- word  : the actual word
The return value is a string with all xml elementes replaced by
clauses: either a cat clause with nested clauses, or a word clause.
The order of the bracket clauses closely follows the xml.
If ordered == True, the word clauses include an order sequence number.
If ordered == False, the word clauses only have pos and word parts.'

def _normalize(self, t, ordered=False):

    if (t[:10] != '<alpino_ds'):
        return ''
    t = re.sub('        <node    .*?    cat="(\\w+)".*>', '(\\1', t)
    if ordered:
        t = re.sub('        <node.    *?begin="(\\d+)".*?    pos="(\\w+)".*?    word="([^"]+)".*?/>', '(\\1    \\2    \\3)', t)
    else:
        t = re.sub('        <node    .*?pos="(\\w+)".*?    word="([^"]+)".*?/>', '(\\1    \\2)', t)
    t = re.sub('        </node>', ')', t)
    t = re.sub('<sentence>.*</sentence>', '', t)
    t = re.sub('</?alpino_ds.*>', '', t)
    return t
