Skip to content

Instantly share code, notes, and snippets.

@ajayjapan
Last active June 24, 2020 03:54
Show Gist options
  • Save ajayjapan/56c270aaa9bf266860268433d30336ad to your computer and use it in GitHub Desktop.
Save ajayjapan/56c270aaa9bf266860268433d30336ad to your computer and use it in GitHub Desktop.
import spacy
nlp = spacy.load("en_core_web_sm")
article = "I have lived in Philadelphia for most of my life. I went to school in New York City."
doc = nlp(article)
[sent for sent in doc.ents]
# Output: [Philadelphia, New York City]
[sent.label_ for sent in doc.ents]
# Output: [‘GPE’, ‘GPE’]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment