The https://github.com/dat/pyner tool is badly outdated.
If you're using NLTK, first update your nltk
version:
pip3 install -U nltk
Then still in terminal:
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-02-27.zip
unzip stanford-corenlp-full-2018-02-27.zip
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -preload tokenize,ssplit,pos,lemma,ner,parse,depparse -status_port 9000 -port 9000 -timeout 15000 &
Then in Python3:
>>> from nltk.parse import CoreNLPParser
>>> tagger = CoreNLPParser(url='http://localhost:9000', tagtype='ner')
>>> tokens = 'Rami Eid is studying at Stony Brook University in NY'.split()
>>>
>>> tagger.tag(tokens)
[('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'), ('at', 'O'), ('Stony', 'ORGANIZATION'), ('Brook', 'ORGANIZATION'), ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'STATE_OR_PROVINCE')]
For Windows
You can use the above using powershell
(which you really do so) but if you like to click on your mouse.
Step 1: Download the zip file from http://nlp.stanford.edu/software/stanford-corenlp-full-2018-02-27.zip
Step 2: Unzip it
Step 3: Open command prompt and go to the folder where file has been unzipped
Step 4: run command: pip3 install -U nltk
Step 5: Now run command:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -preload tokenize,ssplit,pos,lemma,ner,parse,depparse -status_port 9000 -port 9000 -timeout 15000 &
Then in Python3:
>>> from nltk.parse import CoreNLPParser
>>> tagger = CoreNLPParser(url='http://localhost:9000', tagtype='ner')
>>> tokens = 'Rami Eid is studying at Stony Brook University in NY'.split()
>>>
>>> tagger.tag(tokens)
[('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'), ('at', 'O'), ('Stony', 'ORGANIZATION'), ('Brook', 'ORGANIZATION'), ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'STATE_OR_PROVINCE')]