728x90
정규화?
- 데이터 정규화란 학습 데이터의 값들이 일정 범위를 유지하도록 scaling하는 과정을 말한다.
- 자연어 처리에서는 표현 방법이 다른 단어들을 통합시켜서 같은 단어로 만드는 과정을 말한다.
정규화에는 어간 추출(Stemming), 표제어 추출(Lemmatization), 대소문자 통합 등이 있다.
어간 추출과 표제어 추출은 표기가 다은 단어를 하나의 단어로 일반화시켜 문서 내 단어 수를 줄이는 것을 목표로 한다.
표제어 추출의 경우 'am, are, is'를 단어의 원형인 'be'로 바꾸는 것이다. 만약 자연어 생성을 위한 데이터인 경우 원형으로 바꾸는 것은 바람직하지 않다.
# 표제어 추출
nltk.download('wordnet')
nltk.download('omw-1.4')
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
print(lemmatizer.lemmatize('animals', 'n'))
print(lemmatizer.lemmatize('sliding', 'v'))
print(lemmatizer.lemmatize('cups', 'n'))
animal
slide
cup
# 대소문자 통합
text = "I can't believe it's already August! The weather is getting warmer, and the days are getting longer."
# 모든 단어를 소문자로 변환
lowercased_text = text.lower()
print(lowercased_text)
i can't believe it's already august! the weather is getting warmer, and the days are getting longer.
728x90
'자연어 처리(NLP) 공부' 카테고리의 다른 글
뉴스 기사 전처리 시 고려할 것들? (0) | 2023.08.19 |
---|---|
KoNLPy 한국어 형태소 분석기 (1) | 2023.08.18 |
정규표현식으로 특정 문자 삭제하기 (0) | 2023.08.18 |
텍스트 데이터 전처리 - 정제(Cleaning) (0) | 2023.08.18 |
자연어 처리 개요 (0) | 2023.08.16 |