Skip to content

Instantly share code, notes, and snippets.

Last active Jun 13, 2020
What would you like to do?
import nltk
from nltk.tag.stanford import StanfordNERTagger
Named Entity tagging in Python with NLTK and the Stanford NER tagger
PATH_TO_MODEL = '/Users/christina/Projects/stanford_nlp/stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz'
tagger = StanfordNERTagger(model_filename=PATH_TO_MODEL,path_to_jar=PATH_TO_JAR, encoding='utf-8')
sentence = 'First up in London will be Riccardo Tisci, onetime Givenchy darling, favorite of Kardashian-Jenners everywhere, who returns to the catwalk with men’s and women’s wear after a year and a half away, this time to reimagine Burberry after the departure of Christopher Bailey.'
#split the sentence into words
words = nltk.word_tokenize(sentence)
tagged = tagger.tag(words)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment