인프런 커뮤니티 질문&답변
답변 1
0
권 철민
지식공유자
안녕하십니까,
확인 결과 해당 오류는 sentences = sent_tokenize(text=text_sample) 수행 시에 발생하는군요. 전에는 이런 오류가 없었는데, nltk 패키지의 sent_tokenize( ) 함수가 'punkt' 요소를 다운로드를 먼저 받는 방식으로 변경 되었나 봅니다. 아래와 같이 nltk.download('punkt')를 sent_tokenize() 전에 수행하여 'punkt' 요소를 먼저 download 해주십시요. 소중한 정보 감사합니다.
import nltk
nltk.download('punkt')
from nltk import sent_tokenize
text_sample = 'The Matrix is everywhere its all around us, here even in this room. \
You can see it out your window or on your television. \
You feel it when you go to work, or go to church or pay your taxes.'
sentences = sent_tokenize(text=text_sample)
print(type(sentences),len(sentences))
print(sentences)





