Nltk 如何使用PlaintextCorpusReader模块加载一个文本文件语料库
我只能这样做: `从nltk.corpus导入PlaintextCorpusReader 语料库_root='/usr/share/dict' WordList=PlaintextCorpusReader(语料库_根'.*') wordlists.fileids()`Nltk 如何使用PlaintextCorpusReader模块加载一个文本文件语料库,nltk,Nltk,我只能这样做: `从nltk.corpus导入PlaintextCorpusReader 语料库_root='/usr/share/dict' WordList=PlaintextCorpusReader(语料库_根'.*') wordlists.fileids()` 如果我的语料库只有一个文件,那么有没有一个有效的代码可以直接选择该文件而不是这种方法,即对于一个语料库,许多文本文件创建一个目录,只在其中放置一个文件?是的,我就是这么做的!为什么需要明文微粒读取器?如果您只需要标记文本,那么您可
如果我的语料库只有一个文件,那么有没有一个有效的代码可以直接选择该文件而不是这种方法,即对于一个语料库,许多文本文件创建一个目录,只在其中放置一个文件?是的,我就是这么做的!为什么需要
明文微粒读取器
?如果您只需要标记文本,那么您可以轻松地执行[word\u-tokenize(sent)for-sent\u-tokenize(open(filename,'r').read())]
,这将为您提供一个句子列表,每个句子都是一个单词列表。