jjzjj

XMLCorpusReader

全部标签

python - NLTK 的 XMLCorpusReader 可以用于多文件语料库吗?

我正在尝试使用NLTK在NewYorkTimesAnnotatedCorpus上做一些工作其中包含每篇文章的XML文件(采用新闻行业文本格式NITF)。我可以像这样毫无问题地解析单个文档:fromnltk.corpus.readerimportXMLCorpusReaderreader=XMLCorpusReader('nltk_data/corpora/nytimes/1987/01/01',r'0000000.xml')不过我需要处理整个语料库。我试过这样做:reader=XMLCorpusReader('corpora/nytimes',r'.*')但这不会创建可用的阅读器对象。