是否可以在NLTK中使用Stanford Parser?(我不是在谈论斯坦福POS.)
我为这个问题的新手性质道歉 - 我一直试图找出Python包装和名称空间,但更好的观点似乎让我无法理解.也就是说,我想将Python包装器用于斯坦福的词性标注器.我在这里找到文档没有问题,它提供了一个使用示例:
st = StanfordTagger('bidirectional-distsim-wsj-0-18.tagger')
st.tag('What is the airspeed of an unladen swallow ?'.split())
[('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'), ('airspeed', 'NN'), ('of', 'IN'), ('an', 'DT'), ('unladen', 'JJ'), ('swallow', 'VB'), ('?', '.')]
Run Code Online (Sandbox Code Playgroud)
这看起来很棒,但我似乎无法在我的本地Python + NLTK安装中显示正确的命名空间(我有最新的NLTK版本,并在Python 2.6.x以及2.7.x中尝试过以下) :
>>> import nltk
>>> from nltk import *
>>> from nltk.tag import stanford
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name stanford
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个import语句,结果相同:
>>> from nltk.tag.stanford import StanfordTagger
Traceback (most recent call last): …Run Code Online (Sandbox Code Playgroud)