소문자화
여행 웹사이트의 사용자 리뷰를 분석하고 있어요. 리뷰에는 "TRAVEL"과 "travel"처럼 대소문자가 제각각인 경우가 많습니다. 감성 분석과 주제 추출을 위해 먼저 모든 단어를 소문자로 바꾼 다음, 토크나이즈하고 불용어와 문장 부호를 제거할 거예요.
word_tokenize() 함수와 stop_words 목록이 제공되어 있으며, NLTK 리소스는 이미 다운로드되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 배우는 Natural Language Processing (NLP)
연습 안내
- 제공된
review를 소문자로 변환하세요. lower_text를 단어 단위로 토크나이즈하세요.- 리스트 컴프리헨션을 사용해
stop_words와string.punctuation목록을 이용하여 불용어와 문장 부호를 제거하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
review = "I have been FLYING a lot lately and the Flights just keep getting DELAYED. Honestly, traveling for WORK gets exhausting with endless delays, but every trip teaches you something new!"
# Lowercase the review
lower_text = ____
# Tokenize the lower_text into words
tokens = ____
# Remove stop words and punctuation
clean_tokens = [____ if word ____ and word ____]
print(clean_tokens)