Return an integer tuple from
    textual representation of closed / open spans.

def interpret_span(text_spans: str) -> List[int]:
    """
    Return an integer tuple from
    textual representation of closed / open spans.
    """
    m = regex.match("^(?:(?:([\(\[]\d+, \d+[\)\]])|({\d+}))[,]?\s*)+$",
                    text_spans)

    spans = m.captures(1) + m.captures(2)

    int_spans = []
    for span in spans:
        ints = list(map(int,
                        span[1: -1].split(',')))
        if span[0] == '(':
            ints[0] += 1
        if span[-1] == ']':
            ints[1] += 1
        if span.startswith('{'):
            assert(len(ints) == 1)
            ints.append(ints[0] + 1)

        assert(len(ints) == 2)

        int_spans.append(ints)

    # Merge consecutive spans
    ret = []
    cur_span = int_spans[0]
    for (start, end) in int_spans[1:]:
        if start - 1 == cur_span[-1]:
            cur_span = (cur_span[0],
                        end)
        else:
            ret.append(cur_span)
            cur_span = (start, end)

    if (not ret) or (cur_span != ret[-1]):
        ret.append(cur_span)

    return ret[0]