Last active
June 13, 2020 15:34
-
-
Save lvngd/5b3784dfd7638b4cd6bbd892e86e08b5 to your computer and use it in GitHub Desktop.
This file contains 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
import nltk | |
from nltk.tag.stanford import StanfordNERTagger | |
""" | |
Named Entity tagging in Python with NLTK and the Stanford NER tagger | |
""" | |
PATH_TO_JAR='/Users/christina/Projects/stanford_nlp/stanford-ner/stanford-ner.jar' | |
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