
6
장
텍스트 다루기
169
# 텍스트를 만듭니다.
string = "The science of today is the technology of tomorrow"
# 단어를 토큰으로 나눕니다.
word_tokenize(string)
['The', 'science', 'of', 'today', 'is', 'the', 'technology', 'of', 'tomorrow']
문장으로 나눌 수도 있습니다.
# 라이브러리를 임포트합니다.
from nltk.tokenize import sent_tokenize
# 텍스트를 만듭니다.
string = "The science of today is the technology of tomorrow.
Tomorrow is today."
# 문장으로 나눕니다.
sent_tokenize(string)
['The science of today is the technology of tomorrow.', 'Tomorrow is today.']
설명
토큰화
tokenization
, 특히 단어 토큰화는 텍스트 데이터를 정제한 후 빈번하게 수행하는 작
업입니다. 이는 유용한 특성을 만들기 위해 텍스트를 데이터로 변환하는 첫 번째 과정입니다.
(구글의
BERT
같은) 일부 사전 훈련된
NLP
모델은 모델 전용 토큰화 기법을 사용합니다. 하
지만 개별 단어에서 ...