def word_clean(df):
from hanspell import spell_checker
import re
from tqdm import tqdm
CHANGE_FILTER = re.compile("([~!?\"':;&)(])") #제외할 문자
okt = Okt()
X_train = []
for i,sentence in tqdm(enumerate(df)):
sentence = re.sub(CHANGE_FILTER, "", sentence) #문자 제외
ok = spell_checker.check(sentence) # 맞춤법 확인
sentence = ok.checked #바꾼 문자로 변경
clean_words = []
for word in okt.pos(sentence):
if word[1] in ['Noun', 'Modifier', 'Alpha']: #명사, 관형사(가끔 나와서), 영어
clean_words.append(word[0]) #찾아진 것 중 단어만 추가
sentence = ' '.join(clean_words)
X_train.append(sentence)
# print(i,sentence)
return X_train
!pip install git+https://github.com/ssut/py-hanspell.git
!pip install pyspellcheck, !pip install spellcheck 아님
SystemError: java.nio.file.InvalidPathException: Illegal char <*> at index 42: C:\anaconda\Lib\site-packages\konlpy\java\*
처음 colab으로 실행했다 jupyter에서 실행해야 됬었다.
conda activate (가상환경이름)
conda install python=3.8
~로 시작하는 폴더 지우기
vscode로 실행
환경설정 어렵다.
헐 대박