2016-08-29 4 views
0

NLTKからStanfordPOSTaggerを使用しようとしています。スタンフォードPOSのフルタガーをダウンロードしました。私はPythonで次のように入力すると、私はNLTKがスタンフォードPOSタガーモデルファイルを見つけることができません

CLASSPATH=/home/waheeb/Stanford_Tools/stanford-postagger-full-2015-12-09 /stanford-postagger.jar 
STANFORD_MODELS=home/waheeb/Stanford_Tools/stanford-postagger-full-2015-12-09/models 

を設定している:

>>> from nltk.tag import StanfordPOSTagger 
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger') 

私は次のエラーを取得する:

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/home/waheeb/anaconda2/lib/python2.7/site-packages/nltk/tag /stanford.py", line 136, in __init__ 
super(StanfordPOSTagger, self).__init__(*args, **kwargs) 
File "/home/waheeb/anaconda2/lib/python2.7/site-packages/nltk/tag/stanford.py", line 56, in __init__ 
env_vars=('STANFORD_MODELS',), verbose=verbose) 
File "/home/waheeb/anaconda2/lib/python2.7/site-packages /nltk/internals.py", line 573, in find_file 
file_names, url, verbose)) 
File "/home/waheeb/anaconda2/lib/python2.7/site-packages/nltk/internals.py", line 567, in find_file_iter 
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div)) 

LookupErrorが:

========================================================================= 
NLTK was unable to find the english-bidirectional-distsim.tagger file! 
Use software specific configuration paramaters or set the TANFORD_MODELS environment variable. 
========================================================================== 

理由です??

+1

はhttps://gist.github.com/alvations/e1df0ba227e542955a8a – alvas

答えて

1

pythonスクリプトを呼び出す前に、コマンドラインでexportを使用するのを忘れた。私。詳細については

[email protected]:~$ export STANFORDTOOLSDIR=$HOME 
[email protected]:~$ export CLASSPATH=$STANFORDTOOLSDIR/stanford-postagger-full-2015-12-09/stanford-postagger.jar 
[email protected]:~$ export STANFORD_MODELS=$STANFORDTOOLSDIR/stanford-postagger-full-2015-12-09/models 
[email protected]:~$ python 

https://gist.github.com/alvations/e1df0ba227e542955a8a


を参照してください同様の問題が含まれています:

+0

@alvasを参照してください....私はすでにそれらを輸出しました。私はその質問に言及するのを忘れていた。しかし、エラーはまだそこにあります。 –

+1

https://gist.github.com/alvations/e1df0ba227e542955a8aの指示に慎重に従っていますか? – alvas

+0

パーフェクト...ありがとう。 STANFORD_MODELS = /でホームの前に '/'を追加するのを忘れてしまった場合は、 –

関連する問題