[NLP] Python 한글 맞춤법 검사 라이브러리

2023. 9. 21. 09:49ML&DL/NLP

py-hanspell

  • 네이버 맞춤법 검사기를 이용한 파이썬용 한글 맞춤법 검사 라이브러리
  • 맞춤법 교정 기능
  • 자동 띄어쓰기 기능
  • https://github.com/ssut/py-hanspell
 

GitHub - ssut/py-hanspell: 파이썬 한글 맞춤법 검사 라이브러리. (네이버 맞춤법 검사기 사용)

파이썬 한글 맞춤법 검사 라이브러리. (네이버 맞춤법 검사기 사용). Contribute to ssut/py-hanspell development by creating an account on GitHub.

github.com

왜 사용하는가 ?

  • 한국어는 띄어쓰기나 맞춤법이 제대로 지켜지지 않는 경우가 빈번함. 
  • 맞춤법이 틀리면 토큰화를 할 때 같은 단어인데도 다른 단어로 분류되는 문제가 발생

 

언제 사용하는가 ?

  • 토큰화나 데이터 전처리 수행전 맞춤법 교정해주기

 

사용법

  • 라이브러리 불러오기
!pip install git+https://github.com/ssut/py-hanspell.git
from hanspell import spell_checker
  • 맞춤법 교정
sent = "그렇게 하면 않돼지. 왜안되"
spelled_check=spell_checker.check(sent)
hanspell_sent=spelled_check.checked
print(hanspell_sent)
  • 띄어쓰기
sent = "동해물과백두산이마르고닳도록하느님이보우하사우리나라만세무궁화삼천리화려강산"
spelled_check=spell_checker.check(sent)
hanspell_sent=spelled_check.checked
print(hanspell_sent)

 

결과