#!/usr/bin/env python

import logging
import re
import sys

from lbdoc import LineBasedDocument
from paisalib import get_docid

logging.basicConfig(level=logging.INFO)

corpus = LineBasedDocument(sys.stdin)

while corpus.current().startswith('#'):
    corpus.advance()

while not corpus.exhausted():
    sentences = []
    logging.debug(corpus.current())
    docid = get_docid(corpus.current())
    corpus.advance()
    sentence = []
    while not corpus.current().startswith('</text>'):
        if not corpus.current().strip():
            if sentence:
                sentences.append(sentence)
                sentence = []
        else:
            sentence.append(corpus.current().split()[1])
        corpus.advance()
    while not (corpus.exhausted() or corpus.current().startswith('<text ')):
        corpus.advance()
    print '%s\t%s' % (docid, '<SENT>'.join(map(' '.join, sentences)))
