I cannot import NER Stanford Tagger into NLTK. This is what I did:
We downloaded the Java code from here and added the STANFORD_MODELS environment STANFORD_MODELS with the path to the folder where the Java code is stored.
This should be sufficient in accordance with the information provided on the NLTK website. It says:
"Tagger models must be downloaded from http://nlp.stanford.edu/software and set the environment variable STANFORD_MODELS (colon separated list of paths)."
Will anyone be kind to help me please?
EDIT: the downloaded folder is located in the / Users / ----------- / Documents / JavaJuno / stanford-ner-2015-04-20 folder and contains the following files:
LICENSE.txt lib ner.sh stanford-ner-3.5.2-javadoc.jar NERDemo.java ner-gui.bat sample-conll-file.txt stanford-ner-3.5.2-sources.jar README.txt ner-gui.command sample-w-time.txt stanford-ner-3.5.2.jar build.xml ner-gui.sh sample.ner.txt stanford-ner.jar classifiers ner.bat sample.txt
Then I added the STANFORD_MODELS environment variable:
os.environ["STANFORD_MODELS"] = "/Users/-----------/Documents/JavaJuno/stanford-ner-2015-04-20"
A call from nltk.tag import Stanford NERTagger gives an error:
ImportError Traceback (most recent call last) <ipython-input-356-f4287e573edc> in <module>()
Also, if this may be relevant, this is what is in my nltk.tag folder:
__init__.py api.pyc crf.py hmm.pyc senna.py sequential.pyc stanford.py tnt.pyc __init__.pyc brill.py crf.pyc hunpos.py senna.pyc simplify.py stanford.pyc util.py api.py brill.pyc hmm.py hunpos.pyc sequential.py simplify.pyc tnt.py util.pyc
EDIT2: I was able to import the NER tag using:
from nltk.tag.stanford import NERTagger
but now when you call a sample call from the NLTK website, I get:
In [360]: st = NERTagger('english.all.3class.distsim.crf.ser.gz') --------------------------------------------------------------------------- LookupError Traceback (most recent call last) <ipython-input-360-0c0ab770b0ff> in <module>() ----> 1 st = NERTagger('english.all.3class.distsim.crf.ser.gz') /Library/Python/2.7/site-packages/nltk/tag/stanford.pyc in __init__(self, *args, **kwargs) 158 159 def __init__(self, *args, **kwargs): --> 160 super(NERTagger, self).__init__(*args, **kwargs) 161 162 @property /Library/Python/2.7/site-packages/nltk/tag/stanford.pyc in __init__(self, path_to_model, path_to_jar, encoding, verbose, java_options) 40 self._JAR, path_to_jar, 41 searchpath=(), url=_stanford_url, ---> 42 verbose=verbose) 43 44 self._stanford_model = find_file(path_to_model, /Library/Python/2.7/site-packages/nltk/__init__.pyc in find_jar(name, path_to_jar, env_vars, searchpath, url, verbose) 595 (name, url)) 596 div = '='*75 --> 597 raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div)) 598 599 ########################################################################## LookupError: =========================================================================== NLTK was unable to find stanford-ner.jar! Set the CLASSPATH environment variable. For more information, on stanford-ner.jar, see: <http:
Therefore, I set the environment variable incorrectly. Can someone help me with this?