NLTK基本使用

NLTK分句和分词(tokenize)

(1)nltk分句

from nltk.tokenize import sent_tokenize
mytext = "Hello Adam, how are you? I hope everything is going well. Today is a good day, see you dude."
print(sent_tokenize(mytext))

(2)nltk分词

from nltk.tokenize import word_tokenize
mytext = "Hello Mr. Adam, how are you? I hope everything is going well. Today is a good day, see you dude."
print(word_tokenize(mytext))

 

posted on 2021-12-03 22:07  季昂  阅读(83)  评论(0编辑  收藏  举报