How to install and call Stanford NERTagger?

I am trying to use the NLTK interface for Stanford NER in a python environment, nltk.tag.stanford.NERTagger .

 from nltk.tag.stanford import NERTagger st = NERTagger('/usr/share/stanford-ner/classifiers/all.3class.distsim.crf.ser.gz', '/usr/share/stanford-ner/stanford-ner.jar') st.tag('Rami Eid is studying at Stony Brook University in NY'.split()) 

I should get the result:

 [('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'), ('at', 'O'), ('Stony', 'ORGANIZATION'), ('Brook', 'ORGANIZATION'), ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'LOCATION')] 

I installed NLTK in accordance with the procedure described on the website

+5
python nlp nltk stanford-nlp
source share
5 answers

Just thought it was worth mentioning that now the import line:

 from nltk.tag.stanford import StanfordNERTagger 
+11
source share

Perhaps it would be easier to look at the more recent interfaces for Stanford CoreNLP for python, which are available here: http://nlp.stanford.edu/software/corenlp.shtml

+4
source share

You need to download the Stanford package regardless of the NLTK download, put it in the place where the path points and change the directory name in the path described in the NLTK document to any name that it wants to use for the directory. It would be nice if the NLTK documentation stated this explicitly.

+2
source share
 from nltk.tag.stanford import StanfordNERTagger st = StanfordNERTagger('/Users/mahendrabilagi/Desktop/stanford-ner-2017-06-09/classifiers/english.all.3class.distsim.crf.ser.gz', '/Users/mahendrabilagi/Desktop/stanford-ner-2017-06-09/stanford-ner.jar') print st.tag('Rami Eid is studying at Stony Brook University in Bengaluru'.split()) 
+2
source share

Although this answer is for reference only, it will resolve the OP question.

For Windows : https://gist.github.com/alvations/0ed8641d7d2e1941b9f9

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


EDITED

But note that this is not an eternal solution, and since the tools of Stanford NLP and NLTK change more than 2-3 times a year, please check https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software for the latest NLTK API setup instructions for Stanford tools.

The solutions indicated above are posted 03/17/2016

+1
source share

All Articles