将斯坦福pos标记器导入到nltk时遇到麻烦 [英] trouble importing stanford pos tagger into nltk
问题描述
This is probably a very trivial question. I am trying to use the stanford pos tagger through nltk given here The problem is that my nltk lib doesnt contain the stanford module. So I copied the same into the appropriate folder and compiled the same. Now when i try to run an example the module is getting detected but not the class inside the module. Can anyone tell me where I am going wrong?? Again this is probably very dumb.
>>> from nltk.tag import stanford
>>> st = StanfordTagger('bidirection-distsim-wsj-0-18.tagger')
我使用py_compile编译stanford.py文件.我错过了什么吗?
I used py_compile to compile the stanford.py file. Am i missing something
推荐答案
您仅要导入stanford
.要访问StanfordTagger
,您需要使用以下任一方法:
You are only importing stanford
. In order to access StanfordTagger
you need to use either:
>>> from nltk.tag.stanford import StanfordTagger
(假设`StanfordTagger不再嵌套在模块中)或通过以下方式访问
(assuming that `StanfordTagger is not further nested in a module) or access it by
>>> st = stanford.StanfordTagger('bidirection-distsim-wsj-0-18.tagger')
这篇关于将斯坦福pos标记器导入到nltk时遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!