본문 바로가기

python3

python editdistance library 속도 비교(timeit) python editdistance library를 검색하면 다양한 라이브러리가 나옵니다. 그중 editditsance, python-Levenshtein에 대해 속도 비교한 내용입니다. timeit을 배우려고 timeit으로 속도 비교를 해봤습니다. 참고 1, editdistance, https://github.com/roy-ht/editdistance 참고 2, python-Levenshtein, https://maxbachmann.github.io/Levenshtein/ 참고 3, timeit, https://docs.python.org/ko/3/library/timeit.html [timeit — 작은 코드 조각의 실행 시간 측정 — Python 3.11.1 문서 timeit — 작은 코드 조각의.. 2022. 12. 8.
한글의 자모 분리 입력된 문자가 음절인지 확인하고, check_ch_type()음절인 경우 conv_jaso를 통해 자모 분해 & compatibility_jamo로 변환 import unicodedata def check_ch_type(ch): valid_type = ['Lo'] if unicodedata.category(ch) in valid_type: unicode_names = unicodedata.name(ch).split() if 'HANGUL' in unicode_names and 'SYLLABLE' in unicode_names: return True else: return False else: return False def conv_jaso(ch=u'각'): def conv_compatibility_jam.. 2015. 12. 3.
python2.x에서 unicodedata 사용법 파이썬(python)을 이용하여, 한글을 처리할 때 여러가지 방법이 있겠지만, 다음과 같이 unicodedata라는 클래스를 이용하면 좀 더 편리하게 처리할 수 있다. unicodedata documenation : https://docs.python.org/2/library/unicodedata.html unicode type category(5.5.1 General Category Values) : http://www.unicode.org/reports/tr44/tr44-4.html 각 unicode에 대해 어떤 category을 갖는지 확인해서 제거할 수 있으며, 한글의 경우에는 Lo(other characters)에 속한다. 아래 코드는 utf-8 문자열을 입력받아, unicode로 변환한 뒤, .. 2014. 10. 21.