Last active
February 1, 2023 21:53
-
-
Save troyane/c9355a3103ea08679baf to your computer and use it in GitHub Desktop.
Script to prepare Stanford NER to work with your Python and NLTK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir my_project | |
cd my_project | |
echo " . . . Downloading file stanford-ner-2014-08-27.zip" | |
# NOTE: need to update link for further versions | |
wget http://nlp.stanford.edu/software/stanford-ner-2014-08-27.zip | |
echo " . . . Unpacking stanford-ner-2014-08-27.zip" | |
unzip stanford-ner-2014-08-27.zip | |
mkdir stanford-ner | |
cp stanford-ner-2014-08-27/stanford-ner.jar stanford-ner/stanford-ner.jar | |
cp stanford-ner-2014-08-27/classifiers/english.all.3class.distsim.crf.ser.gz stanford-ner/english.all.3class.distsim.crf.ser.gz | |
cp stanford-ner-2014-08-27/classifiers/english.all.3class.distsim.prop stanford-ner/english.all.3class.distsim.prop | |
echo " . . . Clearing all" | |
rm -rf stanford-ner-2014-08-27 stanford-ner-2014-08-27.zip | |
echo " . . . Preparing Python test file test_sner.py" | |
touch test_sner.py | |
# import Stanford NER for NLTK (avaaible from 2.0 ver) | |
echo "from nltk.tag.stanford import NERTagger" >> test_sner.py | |
# initialize SNER using copied files | |
echo "st = NERTagger('stanford-ner/english.all.3class.distsim.crf.ser.gz', 'stanford-ner/stanford-ner.jar')" >> test_sner.py | |
# add test to see weather it works | |
echo "print st.tag('You can call me Billiy Bubu and I live in Amsterdam.'.split())" >> test_sner.py | |
chmod +x test_sner.py | |
echo " . . . Executing Python test file test_sner.py" | |
python test_sner.py | |
echo " . . . Isn't it cool? :)" |
@Shivakishore14 just ran across this as well. It's called StanfordNERTagger
in nltk 3.2.5.
how to run this on windows
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am unable to import
NERTagger
nltk version : 3.2.5