def extract_output(line):
    """
    Extract the index of the tree and the matched tree fragment from a line of Tregex outout.
    """
    line = line.strip()
    index = None
    fragment = None
    for k, c in enumerate(line):
        if c == ':':
            index = line[:k]
            fragment = line[(k+1):].strip()
            break
    assert index is not None
    return int(index), fragment