<p>如果所有的download和环境变量设置都正确,最有可能的原因是文件/目录路径在<code>nltk.parse.malt.py</code>中的<a href="https://github.com/nltk/nltk/blob/develop/nltk/parse/malt.py#L69" rel="nofollow">https://github.com/nltk/nltk/blob/develop/nltk/parse/malt.py#L69</a>中分割,它专门为linux拆分目录和文件名:</p>
<pre><code>def find_maltparser(parser_dirname):
"""
A module to find MaltParser .jar file and its dependencies.
"""
if os.path.exists(parser_dirname): # If a full path is given.
_malt_dir = parser_dirname
else: # Try to find path to maltparser directory in environment variables.
_malt_dir = find_dir(parser_dirname, env_vars=('MALT_PARSER',))
# Checks that that the found directory contains all the necessary .jar
malt_dependencies = ['','','']
_malt_jars = set(find_jars_within_path(_malt_dir))
_jars = set(jar.rpartition('/')[2] for jar in _malt_jars)
malt_dependencies = set(['log4j.jar', 'libsvm.jar', 'liblinear-1.8.jar'])
assert malt_dependencies.issubset(_jars)
assert any(filter(lambda i: i.startswith('maltparser-') and i.endswith('.jar'), _jars))
return list(_malt_jars)
</code></pre>
<p>错误已修复,并且正在<a href="https://github.com/nltk/nltk/pull/1292" rel="nofollow">https://github.com/nltk/nltk/pull/1292</a>处合并</p>
<p>更改此行:</p>
^{pr2}$
<p>这应该可以解决您的问题=)</p>
<pre><code>_jars = set(os.path.split(jar)[1] for jar in _malt_jars)
</code></pre>
<hr/>
<p>答案与代码本身无关,而是如何设置环境变量或下载并保存malt解析器目录或文件,请参见<a href="https://github.com/nltk/nltk/issues/1294" rel="nofollow">https://github.com/nltk/nltk/issues/1294</a></p>