반응형
파이썬 한글 맞춤법 검사 라이브러리
(네이버 맞춤법 검사기 사용)
GitHub - ssut/py-hanspell: 파이썬 한글 맞춤법 검사 라이브러리. (네이버 맞춤법 검사기 사용)
파이썬 한글 맞춤법 검사 라이브러리. (네이버 맞춤법 검사기 사용). Contribute to ssut/py-hanspell development by creating an account on GitHub.
github.com
- AI Boostcamp level1-STS 대회 도중 데이터 전처리를 위해 py-hanspell을 사용
- 맞춤법, 띄어쓰기 교정
오류 발생
!pip3 install git+https://github.com/ssut/py-hanspell.git
from hanspell import spell_checker
checked_sent1 = spell_checker.check("안녕하세요반갑습니다.").checked
checked_sent2 = spell_checker.check("맛춤뻡").checked
print(checked_sent1)
print(checked_sent2)
- py-hanspell spell_checker 사용 시 다음과 같은 KeyError가 발생하였다.

- 깃헙 이슈 등을 뒤지고 뒤져봐도 해결책이 안나왔다.
- [시도1] 안된다 😥
JSONDecodeError: Expecting value; line1 column1(char0) 오류 #31 - [시도2] 안된다 😥 😥 - constant.py 파일의 url 주소 변경
py-hanspell 로 교정하려고 하는데 JSONDecodeError: Expecting value: line 1 column 1 (char 0) 에러가 떠요 - [시도3] 안된다😥 😥 😥 - 위와 같은 KeyError
py-hanspell spell_checker.check 사용 시 KeyError: 'result'
- [시도1] 안된다 😥
˚
˚
˚
3시간은 헤맨 듯😭😨🤯
문제 해결
- 한참 뒤지다가 네이버 블로그 선생님의 기적 같은 포스트를 보게 되었다!!!
hanspell 관련 에러 수정 (23년 11월 7일)
에러가 해결된 상태 (아래 캡쳐) 이 캡쳐는 23년 11월 7일에 얻은 건데, 비슷한 시기에 hanspell 관련해 고...
blog.naver.com
새로 추가된 passportKey 파라미터에 대한 코드 수정 by belowyoon · Pull Request #42 · ssut/py-hanspell
추가된 passportKey라는 파라미터에 대해서 코드 수정했습니다. 처음 1회 때 1시간 동안 유효한 캐시에 네이버 맞춤법 검사 페이지로 부터 passportKey 값을 파싱하여 가져와 저장하고 쓰는 방식입니다
github.com
- 에러 없이 잘 된다!

사용 방법
1. 파일을 다운 받아 작업 중인 code 파일이 있는 곳에 저장한다.
hanspell.zip
0.01MB
2. hanspell.zip 파일의 압축을 해제한 후, hanspell 폴더가 생성됨을 확인한다.
!unzip hanspell.zip
import hanspell
3. import hanspell 후 기존과 같이 사용하면 된다!
from hanspell import spell_checker
checked_sent1 = spell_checker.check("안녕하세요반갑습니다.").checked
checked_sent2 = spell_checker.check("맛춤뻡").checked
print(checked_sent1)
print(checked_sent2)
Reference
- https://github.com/ssut/py-hanspell
- https://blog.naver.com/imw2008/223258509759
- https://github.com/ssut/py-hanspell/pull/42
- https://github.com/ssut/py-hanspell/issues/31
- https://www.codeit.kr/community/questions/UXVlc3Rpb246NjQyMjdiNTZiNThiNmIxODFjNmYyMGVk
- https://github.com/ssut/py-hanspell/issues/41
반응형
LIST