python2 리스트를 청크 단위로 나누기 def list_chunk(source_list, n): """ 리스트를 청크 단위로 잘라낸다. """ return [source_list[i:i+n] for i in range(0, len(source_list), n)] 2021. 3. 28. 정규화 import re def name_norm(text): print 'target: ' + text text = re.sub(r" ?\([^)]+\)", "", text).strip() print 'step1: ' + text text = re.sub('[-=+.,#/?*:$!}]', ' ', text).strip() print 'step2: ' + text text = ' '.join(text.split()).strip() print 'step3: ' + text return text name_norm("a,b") name_norm("a (a)") 2020. 12. 17. 이전 1 다음