

def _verify(self, s, verify_tags):
    '\n        Check to make sure that ``s`` still corresponds to some chunked\n        version of ``_pieces``.\n\n        :type verify_tags: bool\n        :param verify_tags: Whether the individual tags should be\n            checked.  If this is false, ``_verify`` will check to make\n            sure that ``_str`` encodes a chunked version of *some*\n            list of tokens.  If this is true, then ``_verify`` will\n            check to make sure that the tags in ``_str`` match those in\n            ``_pieces``.\n\n        :raise ValueError: if the internal string representation of\n            this ``ChunkString`` is invalid or not consistent with _pieces.\n        '
    if (not ChunkString._VALID.match(s)):
        raise ValueError(('Transformation generated invalid chunkstring:\n  %s' % s))
    brackets = ChunkString._BRACKETS.sub('', s)
    for i in range((1 + (len(brackets) // 5000))):
        substr = brackets[(i * 5000):((i * 5000) + 5000)]
        if (not ChunkString._BALANCED_BRACKETS.match(substr)):
            raise ValueError(('Transformation generated invalid chunkstring:\n  %s' % s))
    if (verify_tags <= 0):
        return
    tags1 = re.split('[\\{\\}<>]+', s)[1:(- 1)]
    tags2 = [self._tag(piece) for piece in self._pieces]
    if (tags1 != tags2):
        raise ValueError('Transformation generated invalid chunkstring: tag changed')

dataset/ETHPy150Open nltk/nltk/nltk/chunk/regexp.py ChunkString._verify/original