(self, parentheses)
更新括号权重
更新括号权重
更新括号权重
def _update_parentheses_ptn(self, parentheses):
        ''' 更新括号权重 '''
        length = len(parentheses)
        assert len(parentheses) % 2 == 0

        remove_ptn_list = []
        remove_ptn_format = '{left}[^{left}{right}]*{right}'
        for i in range(0, length, 2):
            left = re.escape(parentheses[i])
            right = re.escape(parentheses[i + 1])
            remove_ptn_list.append(remove_ptn_format.format(left=left, right=right))
        remove_ptn = '|'.join(remove_ptn_list)
        
        self.remove_parentheses_ptn = re.compile(remove_ptn)
        self.parentheses = parentheses
def _update_parentheses_ptn ( self , parentheses ) : length = len ( parentheses ) assert len ( parentheses ) % 2 == 0 remove_ptn_list = [ ] remove_ptn_format = '{left}[^{left}{right}]*{right}' for i in range ( 0 , length , 2 ) : left = re . escape ( parentheses [ i ] ) right = re . escape ( parentheses [ i + 1 ] ) remove_ptn_list . append ( remove_ptn_format . format ( left = left , right = right ) ) remove_ptn = '|' . join ( remove_ptn_list ) self . remove_parentheses_ptn = re . compile ( remove_ptn ) self . parentheses = parentheses