

def __init__(self, left_context_tag_pattern, chunk_tag_pattern, right_context_tag_pattern, descr):
    '\n        Construct a new ``ChunkRuleWithContext``.\n\n        :type left_context_tag_pattern: str\n        :param left_context_tag_pattern: A tag pattern that must match\n            the left context of ``chunk_tag_pattern`` for this rule to\n            apply.\n        :type chunk_tag_pattern: str\n        :param chunk_tag_pattern: A tag pattern that must match for this\n            rule to apply.  If the rule does apply, then this pattern\n            also identifies the substring that will be made into a chunk.\n        :type right_context_tag_pattern: str\n        :param right_context_tag_pattern: A tag pattern that must match\n            the right context of ``chunk_tag_pattern`` for this rule to\n            apply.\n        :type descr: str\n        :param descr: A short description of the purpose and/or effect\n            of this rule.\n        '
    re.compile(tag_pattern2re_pattern(left_context_tag_pattern))
    re.compile(tag_pattern2re_pattern(chunk_tag_pattern))
    re.compile(tag_pattern2re_pattern(right_context_tag_pattern))
    self._left_context_tag_pattern = left_context_tag_pattern
    self._chunk_tag_pattern = chunk_tag_pattern
    self._right_context_tag_pattern = right_context_tag_pattern
    regexp = re.compile(('(?P<left>%s)(?P<chunk>%s)(?P<right>%s)%s' % (tag_pattern2re_pattern(left_context_tag_pattern), tag_pattern2re_pattern(chunk_tag_pattern), tag_pattern2re_pattern(right_context_tag_pattern), ChunkString.IN_CHINK_PATTERN)))
    replacement = '\\g<left>{\\g<chunk>}\\g<right>'
    RegexpChunkRule.__init__(self, regexp, replacement, descr)

dataset/ETHPy150Open nltk/nltk/nltk/chunk/regexp.py ChunkRuleWithContext.__init__/original