这是我第一次使用StackOverflow提出一个问题,但是我已经集体保存了这么多年来我在家里感受到的许多项目.
我正在使用Python3.5和nltk来解析旧英语的完整语料库,它作为77个文本文件和XML文档发布给我,它将文件序列指定为TEI格式语料库的连续段.以下是XML文档标题的相关部分,显示我们实际上正在使用TEI:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader type="ISBD-ER">
<fileDesc>
Run Code Online (Sandbox Code Playgroud)
是的,所以作为测试,我只是试图使用NLTK的MTECorpusReader打开语料库并使用words()方法来证明我能够打开它.我正在通过交互式Python shell完成所有这些工作,只是为了便于测试.这就是我所做的一切:
# import the reader method
import nltk.corpus.reader as reader
# open the sequence of files and the XML doc with the MTECorpusReader
oecorpus = reader.mte.MTECorpusReader('/Users/me/Documents/0163','.*')
# print the first few words in the corpus to the interactive shell
oecorpus.words()
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,我得到以下回溯:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nltk/util.py", line 765, in __repr__
for elt in self:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nltk/corpus/reader/util.py", line 397, in iterate_from
for …Run Code Online (Sandbox Code Playgroud)