0

I am trying using Stanford's Name Entity Recognizer(NER).

I downloaded the zip file from : https://github.com/dat/pyner.

Installed it using: python setup.py install.

Now when I am running the below command, I am getting blank output

import ner
tagger =ner.SocketNER(host='localhost',port=31752,output_format='slashTags')
tagger.get_entities("University of California is located in California, United States")

Output:
{}

am I missing anything?

alvas
  • 115,346
  • 109
  • 446
  • 738
Slickmind
  • 442
  • 1
  • 7
  • 15

1 Answers1

2

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')]
alvas
  • 115,346
  • 109
  • 446
  • 738
  • https://stackoverflow.com/questions/52031337/stanfords-corenlp-name-entity-recogniser-throwing-error-500-server-error-inter Can you please help in this – Slickmind Aug 27 '18 at 00:55