-
불용어 / tqdm 파이썬 진행률 프로그래스바IT/파이썬 2025. 1. 21. 16:06
불용어란?
I, my, me, over, 조사, 접미사 같은 단어들
문장에서는 자주 등장하지만
실제 의미 분석을 하는데는 거의 기여하는 바가 없는 단어
>우리나라 말로 따지면 의미 없는 조사같은 것들
참고 자료 : 위키독스
tqdm ?
tqdm은 파이썬에서 작업이 진행될 때,
프로그래스바로 보여주는 역할을 함

AssertionError Traceback (most recent call last)
<ipython-input-18-8ee890657fa5> in <cell line: 9>()
8 tokenized_data = []
9 for sentence in tqdm.tqdm(train_data['document']):
---> 10 tokenized_sentence = okt.morphs(sentence, stem=True) # 토큰화
11 stopwords_removed_sentence = [word for word in tokenized_sentence if not word in stopwords] # 불용어 제거
12 tokenized_data.append(stopwords_removed_sentence)
/usr/local/lib/python3.10/dist-packages/konlpy/tag/_okt.py in morphs(self, phrase, norm, stem)
87 """Parse phrase to morphemes."""
88
---> 89 return [s for s, t in self.pos(phrase, norm=norm, stem=stem)]
90
91 def phrases(self, phrase):
/usr/local/lib/python3.10/dist-packages/konlpy/tag/_okt.py in pos(self, phrase, norm, stem, join)
67 :param join: If True, returns joined sets of morph and tag.
68 """
---> 69 validate_phrase_inputs(phrase)
70
71 tokens = self.jki.tokenize(
/usr/local/lib/python3.10/dist-packages/konlpy/tag/_common.py in validate_phrase_inputs(phrase)
18 """
19 msg = "phrase input should be string, not %s" % type(phrase)
---> 20 assert isinstance(phrase, basestring), msg
AssertionError: phrase input should be string, not <class 'float'>
add Codeadd Markdown위와 같은 에러가 생겨서 아래 처럼 코드를 수정함
sentence = str(sentence)
str형식으로 변환함
import tqdm # 불용어 정의 stopwords = ['의','가','이','은','들','는','좀','잘','걍','과','도','를','으로','자','에','와','한','하다'] # 형태소 분석기 OKT를 사용한 토큰화 작업 (다소 시간 소요) okt = Okt() tokenized_data = [] for sentence in tqdm.tqdm(train_data['document']): sentence = str(sentence) tokenized_sentence = okt.morphs(sentence, stem=True) # 토큰화 stopwords_removed_sentence = [word for word in tokenized_sentence if not word in stopwords] # 불용어 제거 tokenized_data.append(stopwords_removed_sentence)
위 실습예제 : https://wikidocs.net/217114
12-04 Word2Vec 학습 및 시각화
gensim 패키지에서 제공하는 이미 구현된 Word2Vec을 사용하여 영어와 한국어 데이터를 학습합니다. ## 1. 영어 Word2Vec 만들기 파이썬의 gensim 패키지…
wikidocs.net
'IT > 파이썬' 카테고리의 다른 글
파이썬 venv 가상환경 만들기 — 프로젝트별 독립 개발환경 구축법 (0) 2025.07.14 파이썬 버전 어떤 걸 설치 해야 할까? (1) 2025.07.12 LSTM(Long Short-Term Memory) 모델 학습을 위한 시계열 데이터 전처리 (0) 2025.04.26 파이썬 설치 경로 찾기 (0) 2025.01.20