I just updated to the last version nltk and run the following code but got errors: NLTK was unable to find the java file!
It's odd since the first line output says it found java executables but later it complains again about the java file! I want to make it work asap. I will wait online!!! Thanks
import nltk
from nltk.tag.stanford import StanfordTagger
nltk.internals.config_java("C:/Program Files/Java/jdk1.7.0_04/bin/java.exe")
path_to_model = "C:/Dropbox/_Ubuntu/project/NLTK/src/lib/wsj-0-18-bidirectional-distsim.tagger"
path_to_jar = "C:/Dropbox/_Ubuntu/project/NLTK/src/lib/stanford-postagger.jar"
tagger = StanfordTagger(path_to_model, path_to_jar)
tokens = nltk.tokenize.word_tokenize("I hope this works!")
print tagger.tag(tokens)
[Found C:/Program Files/Java/jdk1.7.0_04/bin/java.exe: C:/Program Files/Java/jdk1.7.0_04/bin/java.exe]
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\test.py", line 9, in <module>
print tagger.tag(tokens)
File "C:\Python27\lib\site-packages\nltk\tag\stanford.py", line 54, in tag
return self.batch_tag([tokens])[0]
File "C:\Python27\lib\site-packages\nltk\tag\stanford.py", line 59, in batch_tag
config_java(options=self.java_options, verbose=False)
File "C:\Python27\lib\site-packages\nltk\internals.py", line 90, in config_java
_java_bin = find_binary('java', bin, env_vars=['JAVAHOME', 'JAVA_HOME'], verbose=verbose)
File "C:\Python27\lib\site-packages\nltk\internals.py", line 528, in find_binary
url, verbose)
File "C:\Python27\lib\site-packages\nltk\internals.py", line 512, in find_file
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError:
===========================================================================
NLTK was unable to find the java file!
Use software specific configuration paramaters or set the JAVAHOME environment variable.
===========================================================================