반응형
HTS 나 스마트폰에서 초성 검색을 많이 사용하실 걸로 생각 합니다. 이렇게 초성 검색을 하고 싶을 때는Python jamo 라이브러리를 사용하시면 됩니다.
jamo 라이브러리의 홈페이지 주소는 아래와 같습니다.
https://github.com/JDongian/python-jamo
아래와 같이 pip 명령어로 쉽게 설치 할 수 있습니다.
pip install jamo
사용방법은 아래 문서를 확인하시면 되고
https://python-jamo.readthedocs.io/en/latest/
https://python-jamo.readthedocs.io/en/latest/sample.html#sample-usage
제가 사용해본 샘플 코드는 아래와 같습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from jamo import h2j, j2hcj | |
allInit = [] | |
text = "삼성전자" | |
for x in text: | |
temp = h2j(x) | |
imf = j2hcj(temp) # init,middle,final | |
print(f"{temp}, {imf}") | |
allInit.append(imf[0]) | |
print("".join(allInit)) |
삼성전자 입력시 아래와 같이 초성인 “ㅅㅅㅈㅈ” 가 결과로 나오는 것을 확인 할 수 있습니다.

반응형
'programming language > Python' 카테고리의 다른 글
Python 데코레이터 유용한 예제 lru_cache (0) | 2022.10.12 |
---|---|
Python 셀레늄 열려있는 브라우저 자동화하기 (949) | 2022.08.28 |
IPython 세팅 파일 위치 (0) | 2021.12.25 |
Python 을 사용하여 숫자를 글자로 읽기 (0) | 2021.10.20 |
Python 주식 시장 개장일/휴장일 대체휴일 확인하기 (0) | 2021.10.11 |
Python 주가의 지지선 저항선을 찾는 방법 (587) | 2021.10.10 |
Python 주식 시장 개장일/휴장일 확인하기 (0) | 2021.09.23 |
Python exe 파일 만들기 PyInstaller, auto-py-to-exe (6) | 2020.07.05 |
댓글