1.获取文本语料库
1.1古滕堡语料库
nltk.corpus.gutenberg.fileids()//古滕堡语料库文件标识符
emma = nltk.corpus.gutenberg.words('austen-emma.txt')emma = nltk.Text(nltk.corpus.gutenberg.words('austen-emma.txt'))//我们调用了NLTK 中的corpus 包中的gutenberg 对象的words()函数
emma.concordance("surprize")//获取包含suprize得上下文
macbeth_sentences = gutenberg.sents('shakespeare-macbeth.txt')//sents()函数把文本划分成句子,其中每一个句子是一个词链表。
1.2网络和聊天文本
from nltk.corpus import webtext
from nltk.corpus import webtext
>>> for fileid in webtext.fileids():
... print (fileid, webtext.raw(fileid)[:65], '...')
from nltk.corpus import nps_chat
chatroom = nps_chat.posts('10-19-20s_706posts.

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



